SUMMARY Checking a program that uses boost's iostreams::mapped_file causes valgrind to crash with "unrecognized instruction" on an amd64 architecture. STEPS TO REPRODUCE 1. Simple Testprogramm #include <boost/spirit/include/qi.hpp> #include <boost/iostreams/device/mapped_file.hpp> bool read_DOUBLES(const std::string& filename, std::vector<double>& values, const int N) { boost::iostreams::mapped_file mmap(filename, boost::iostreams::mapped_file::mapmode::readonly); auto f = mmap.const_data(); auto l = f + mmap.size(); values.reserve(N); boost::spirit::qi::phrase_parse(f, l, +boost::spirit::qi::double_, boost::spirit::qi::space, values); return 0; } int main(const int, const char** argv) { std::vector<double> data_vector; read_DOUBLES("Textfile.txt", data_vector, 10); return 0; } 2. Run valgrind on it OBSERVED RESULT: vex amd64->IR: unhandled instruction bytes: 0x62 0x91 0x7F 0x28 0x6F 0x4 0x3 0x62 0x91 0x7F vex amd64->IR: REX=0 REX.W=0 REX.R=0 REX.X=0 REX.B=0 vex amd64->IR: VEX=0 VEX.L=0 VEX.nVVVV=0x0 ESC=NONE vex amd64->IR: PFX.66=0 PFX.F2=0 PFX.F3=0 ==221533== valgrind: Unrecognised instruction at address 0x4035c90. ==221533== at 0x4035C90: mempcpy (vg_replace_strmem.c:1540) ==221533== by 0x400587F: open_path (in /usr/lib64/ld-2.17.so) ==221533== by 0x4008776: _dl_map_object (in /usr/lib64/ld-2.17.so) ==221533== by 0x400CC61: openaux (in /usr/lib64/ld-2.17.so) ==221533== by 0x400F7D3: _dl_catch_error (in /usr/lib64/ld-2.17.so) ==221533== by 0x400D46C: _dl_map_object_deps (in /usr/lib64/ld-2.17.so) ==221533== by 0x4003692: dl_main (in /usr/lib64/ld-2.17.so) ==221533== by 0x401800D: _dl_sysdep_start (in /usr/lib64/ld-2.17.so) ==221533== by 0x4001BD0: _dl_start (in /usr/lib64/ld-2.17.so) ==221533== by 0x4001147: ??? (in /usr/lib64/ld-2.17.so) ==221533== Your program just tried to execute an instruction that Valgrind ==221533== did not recognise. There are two possible reasons for this. ==221533== 1. Your program has a bug and erroneously jumped to a non-code ==221533== location. If you are running Memcheck and you just saw a ==221533== warning about a bad jump, it's probably your program's fault. ==221533== 2. The instruction is legitimate but Valgrind doesn't handle it, ==221533== i.e. it's Valgrind's fault. If you think this is the case or ==221533== you are not sure, please let us know and we'll try to fix it. ==221533== Either way, Valgrind will now raise a SIGILL signal which will ==221533== probably kill your program. EXPECTED RESULT No Crash. (Runs error-free on Fedora 31) SOFTWARE/OS VERSIONS Windows: macOS: Linux/KDE Plasma: CentOS Linux 7 Kernel: Linux 3.10.0-1127.13.1.el7.x86_64 Architecture: x86-64
That's an AVX512 instruction and those aren't supported yet. It's not actually the boost code that's the issue by the way, it's actually the mempcpy replacement routine in valgrind so valgrind must have been compiled with -march=native or some other option that enabled avx512 support. *** This bug has been marked as a duplicate of bug 383010 ***