Search code examples
c++gccg++valgrind

gcc / C++ Disable generation of vex instructions


We are debugging memory issues with our large legacy app and would like to use Valgrind to track it down. The app uses the ACE/TAO CORBA library however, Valgrind complains of illegal "vex" instructions in the library.

==29992== Memcheck, a memory error detector
==29992== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==29992== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==29992== Command: DvMain
==29992==
DvMain. Version 6.0  Build 38B16
vex x86->IR: unhandled instruction bytes: 0xC4 0xE2 0x7B 0xF7
==29992== valgrind: Unrecognised instruction at address 0x5f37a4b.
==29992==    at 0x5F37A4B: ACE_Select_Reactor_Impl::bit_ops(int, unsigned long, ACE_Select_Reactor_Handle_Set&, int) (in /usr/local/dvstation/lib3p/ACE/libACE.so.6.2.7)

In another SO question, VTT suggested disabling AVX instructions with -mno-avx, which worked on some things. However, still have problems.

I've tried -mno-sse2avx -mno-avx -mno-sse4.1 -mno-sse4.2 -mno-sse4 -mno-sse4a but Valgrind still complains of vex instructions in ::bit_ops() (If you are interested, bit_ops is defined on line 956 of this file)

How do I disable completely the generation of VEX instructions so I can use Valgrind to debug?

Platform is 32-bit Centos 6, g++ 4.9.4

(please don't suggest moving to 64-bit. That's not an option with this product)

Reference:

Compile line for offending file:

/usr/local/gcc-4.9.4/bin/c++4.9  -mno-sse2avx -fvisibility=hidden 
-fvisibility-inlines-hidden -fdiagnostics-color=auto 
-mno-avx -mno-sse4.1 -mno-sse4.2 -mno-sse4 -mno-sse4a 
-O3 -march=native -pthread -fno-strict-aliasing 
-Wall -W -Wpointer-arith -pipe -D_GNU_SOURCE  
-c -fPIC -o .shobj/Select_Reactor_Base.o Select_Reactor_Base.cpp

Solution

  • VEX is pretty new. Using an old architecture, e.g. -march=pentium4 will disallow VEX instruction coding, but you keep SSE2.