Bug 273230

Summary: avx instructions not handled?
Product: [Developer tools] valgrind Reporter: Kevin Mitchell <kevmitch>
Component: generalAssignee: Julian Seward <jseward>
Status: RESOLVED DUPLICATE    
Severity: normal CC: Enrico_m, kevmitch, tim
Priority: NOR    
Version: 3.7 SVN   
Target Milestone: ---   
Platform: Debian unstable   
OS: Linux   
Latest Commit: Version Fixed In:

Description Kevin Mitchell 2011-05-13 23:37:47 UTC
Version:           3.7 SVN
OS:                Linux

When enabling avx optimisations on a sandy bridge processor with gcc-4.6, valgrind complains of illegal instruction: 0xC5 0xF9 0x6F 0x5 0x1 0x2 0x0 0x0


Reproducible: Didn't try

Steps to Reproduce:
I write the following simple fortran program
=====valgrind_avx.f90======
program main
 implicit none
  integer,parameter:: n=16
  integer          :: ii(n)
  ii=1
  print*,ii
  return
end program
=============================

compile with avx opts and run valgrind on it
$ gfortran-4.6 -g -march=corei7-avx -O3 valgrind_avx.f90
$ valgrind ./a.out




Actual Results:  
==2358== Memcheck, a memory error detector
==2358== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==2358== Using Valgrind-3.7.0.SVN and LibVEX; rerun with -h for copyright info
==2358== Command: ./a.out
==2358== 
vex amd64->IR: unhandled instruction bytes: 0xC5 0xF9 0x6F 0x5 0x1 0x2 0x0 0x0
==2358== valgrind: Unrecognised instruction at address 0x4007b7.
==2358==    at 0x4007B7: MAIN__ (valgrind_avx.f90:5)
==2358==    by 0x4006BC: main (valgrind_avx.f90:8)
==2358== Your program just tried to execute an instruction that Valgrind
==2358== did not recognise.  There are two possible reasons for this.
==2358== 1. Your program has a bug and erroneously jumped to a non-code
==2358==    location.  If you are running Memcheck and you just saw a
==2358==    warning about a bad jump, it's probably your program's fault.
==2358== 2. The instruction is legitimate but Valgrind doesn't handle it,
==2358==    i.e. it's Valgrind's fault.  If you think this is the case or
==2358==    you are not sure, please let us know and we'll try to fix it.
==2358== Either way, Valgrind will now raise a SIGILL signal which will
==2358== probably kill your program.
==2358== 
==2358== Process terminating with default action of signal 4 (SIGILL)
==2358==  Illegal opcode at address 0x4007B7
==2358==    at 0x4007B7: MAIN__ (valgrind_avx.f90:5)
==2358==    by 0x4006BC: main (valgrind_avx.f90:8)
==2358== 
==2358== HEAP SUMMARY:
==2358==     in use at exit: 3,807 bytes in 16 blocks
==2358==   total heap usage: 20 allocs, 4 frees, 11,947 bytes allocated
==2358== 
==2358== LEAK SUMMARY:
==2358==    definitely lost: 0 bytes in 0 blocks
==2358==    indirectly lost: 0 bytes in 0 blocks
==2358==      possibly lost: 0 bytes in 0 blocks
==2358==    still reachable: 3,807 bytes in 16 blocks
==2358==         suppressed: 0 bytes in 0 blocks
==2358== Rerun with --leak-check=full to see details of leaked memory
==2358== 
==2358== For counts of detected and suppressed errors, rerun with: -v
==2358== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2)
Illegal instruction


Expected Results:  
Same as I get when I compile instead with
$ gfortran-4.6 -g -march=corei7 -O3 valgrind_avx.f90

==2364== Memcheck, a memory error detector
==2364== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==2364== Using Valgrind-3.7.0.SVN and LibVEX; rerun with -h for copyright info
==2364== Command: ./a.out
==2364== 
           1           1           1           1           1           1           1           1           1           1           1           1           1           1           1           1
==2364== 
==2364== HEAP SUMMARY:
==2364==     in use at exit: 0 bytes in 0 blocks
==2364==   total heap usage: 20 allocs, 20 frees, 11,947 bytes allocated
==2364== 
==2364== All heap blocks were freed -- no leaks are possible
==2364== 
==2364== For counts of detected and suppressed errors, rerun with: -v
==2364== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2)
Comment 1 Kevin Mitchell 2011-05-13 23:38:58 UTC
Sorry, "Reproducible: Didn't try" should be "Reproducible: Happens every time"
Comment 2 Julian Seward 2011-10-05 07:53:32 UTC

*** This bug has been marked as a duplicate of bug 273475 ***