valgrind-macos icon indicating copy to clipboard operation
valgrind-macos copied to clipboard

Illegal instruction error for SSE4 instructions on self-hosting 32-bit build

Open nmosier opened this issue 3 years ago • 1 comments

I built valgrind with the following: ./configure --enable-only32bit --enable-inner and the build succeeded (I'm on macOS 10.14 w/ a 32-bit SDK).

However, when I run valgrind on any program, it aborts with the following error:

==84784== Memcheck, a memory error detector
==84784== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==84784== Using Valgrind-3.18.0.GIT-lbmacos and LibVEX; rerun with -h for copyright info
==84784== Command: ../tmp
==84784== 
--84784-- WARNING: Serious error when reading debug info
--84784-- When reading debug info from ../tmp:
--84784-- Invalid Mach-O file (bad magic).
--84784-- WARNING: Serious error when reading debug info
--84784-- When reading debug info from ../tmp:
--84784-- Error reading Mach-O object.
--84784-- WARNING: Serious error when reading debug info
--84784-- When reading debug info from ../tmp:
--84784-- Invalid Mach-O file (bad magic).
--84784-- WARNING: Serious error when reading debug info
--84784-- When reading debug info from ../tmp:
--84784-- Error reading Mach-O object.
vex x86->IR: unhandled instruction bytes: 0x66 0xF 0x38 0x35
==84784== valgrind: Unrecognised instruction at address 0x26e5a.
==84784==    at 0x26E5A: ___ZNK5dyld39MachOFile14forEachSegmentEU13block_pointerFvRKNS0_11SegmentInfoERbE_block_invoke (in /usr/lib/dyld)
==84784==    by 0x268B6: dyld3::MachOFile::forEachLoadCommand(Diagnostics&, void ( block_pointer)(load_command const*, bool&)) const (in /usr/lib/dyld)
==84784==    by 0x26CB4: dyld3::MachOFile::forEachSegment(void ( block_pointer)(dyld3::MachOFile::SegmentInfo const&, bool&)) const (in /usr/lib/dyld)
==84784==    by 0x265CA: dyld3::MachOLoaded::intersectsRange(unsigned long, unsigned long) const (in /usr/lib/dyld)
==84784==    by 0xAA15: dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) (in /usr/lib/dyld)
==84784==    by 0x55BC: dyldbootstrap::start(macho_header const*, int, char const**, long, macho_header const*, unsigned long*) (in /usr/lib/dyld)
==84784==    by 0x5046: _dyld_start (in /usr/lib/dyld)
==84784== Your program just tried to execute an instruction that Valgrind
==84784== did not recognise.  There are two possible reasons for this.
==84784== 1. Your program has a bug and erroneously jumped to a non-code
==84784==    location.  If you are running Memcheck and you just saw a
==84784==    warning about a bad jump, it's probably your program's fault.
==84784== 2. The instruction is legitimate but Valgrind doesn't handle it,
==84784==    i.e. it's Valgrind's fault.  If you think this is the case or
==84784==    you are not sure, please let us know and we'll try to fix it.
==84784== Either way, Valgrind will now raise a SIGILL signal which will
==84784== probably kill your program.
==84784== 
==84784== Process terminating with default action of signal 4 (SIGILL)
==84784==  Illegal opcode at address 0x26E5A
==84784==    at 0x26E5A: ___ZNK5dyld39MachOFile14forEachSegmentEU13block_pointerFvRKNS0_11SegmentInfoERbE_block_invoke (in /usr/lib/dyld)
==84784==    by 0x268B6: dyld3::MachOFile::forEachLoadCommand(Diagnostics&, void ( block_pointer)(load_command const*, bool&)) const (in /usr/lib/dyld)
==84784==    by 0x26CB4: dyld3::MachOFile::forEachSegment(void ( block_pointer)(dyld3::MachOFile::SegmentInfo const&, bool&)) const (in /usr/lib/dyld)
==84784==    by 0x265CA: dyld3::MachOLoaded::intersectsRange(unsigned long, unsigned long) const (in /usr/lib/dyld)
==84784==    by 0xAA15: dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) (in /usr/lib/dyld)
==84784==    by 0x55BC: dyldbootstrap::start(macho_header const*, int, char const**, long, macho_header const*, unsigned long*) (in /usr/lib/dyld)
==84784==    by 0x5046: _dyld_start (in /usr/lib/dyld)
==84784== 
==84784== HEAP SUMMARY:
==84784==     in use at exit: 0 bytes in 0 blocks
==84784==   total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==84784== 
==84784== All heap blocks were freed -- no leaks are possible
==84784== 
==84784== For lists of detected and suppressed errors, rerun with: -s
==84784== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 4 from 4)
Illegal instruction: 4

(../tmp is a 32-bit program that does nothing.) The instruction it's complaining about is an SSE4 instruction. Any way to fix this? I need to be able to use valgrind on 32-bit executables, and recompiling those executables is not an option.

nmosier avatar Apr 25 '21 14:04 nmosier

Hi @nmosier,

Thanks for the report! That's really odd... could you get me the version of your Xcode, SDK, etc so I could replicate it on my own 10.14?

LouisBrunner avatar Aug 23 '21 18:08 LouisBrunner

Closing this due to inactivity. Please reopen with more details and/or a reproducible example if the issue persists.

LouisBrunner avatar Jan 02 '23 22:01 LouisBrunner