I get the error shown below when my program calls the std::mt19937 constructor: std::random_device rd; std::mt19937 gen( rd() ); Valgrind runs through the whole program when `gen` is not created. gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609 valgrind-3.11.0 Kubuntu Linux (Xenial), 4.4.0-66-generic, x86_64 ==21189== Memcheck, a memory error detector ==21189== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al. ==21189== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info ==21189== Command: ./unit_tests ==21189== --21189-- Valgrind options: --21189-- -v --21189-- Contents of /proc/version: --21189-- Linux version 4.4.0-66-generic (buildd@lgw01-28) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) ) #87-Ubuntu SMP Fri Mar 3 15:29:05 UTC 2017 --21189-- --21189-- Arch and hwcaps: AMD64, LittleEndian, amd64-cx16-lzcnt-rdtscp-sse3-avx-avx2-bmi --21189-- Page sizes: currently 4096, max supported 4096 --21189-- Valgrind library directory: /usr/lib/valgrind --21189-- Reading syms from /home/cris/SW/tIA/cellmap_talis/diplib/target/unit_tests --21189-- Reading syms from /lib/x86_64-linux-gnu/ld-2.23.so --21189-- Considering /lib/x86_64-linux-gnu/ld-2.23.so .. --21189-- .. CRC mismatch (computed 10768843 wanted ef0d0121) --21189-- Considering /usr/lib/debug/lib/x86_64-linux-gnu/ld-2.23.so .. --21189-- .. CRC is valid --21189-- Reading syms from /usr/lib/valgrind/memcheck-amd64-linux --21189-- Considering /usr/lib/valgrind/memcheck-amd64-linux .. --21189-- .. CRC mismatch (computed 5529a2c7 wanted 5bd23904) --21189-- object doesn't have a symbol table --21189-- object doesn't have a dynamic symbol table --21189-- Scheduler: using generic scheduler lock implementation. --21189-- Reading suppressions file: /usr/lib/valgrind/default.supp ==21189== embedded gdbserver: reading from /tmp/vgdb-pipe-from-vgdb-to-21189-by-cris-on-??? ==21189== embedded gdbserver: writing to /tmp/vgdb-pipe-to-vgdb-from-21189-by-cris-on-??? ==21189== embedded gdbserver: shared mem /tmp/vgdb-pipe-shared-mem-vgdb-21189-by-cris-on-??? ==21189== ==21189== TO CONTROL THIS PROCESS USING vgdb (which you probably ==21189== don't want to do, unless you know exactly what you're doing, ==21189== or are doing some strange experiment): ==21189== /usr/lib/valgrind/../../bin/vgdb --pid=21189 ...command... ==21189== ==21189== TO DEBUG THIS PROCESS USING GDB: start GDB like this ==21189== /path/to/gdb ./unit_tests ==21189== and then give GDB the following command ==21189== target remote | /usr/lib/valgrind/../../bin/vgdb --pid=21189 ==21189== --pid is optional if only one valgrind process is running ==21189== --21189-- REDIR: 0x401cdc0 (ld-linux-x86-64.so.2:strlen) redirected to 0x3809e181 (???) --21189-- Reading syms from /usr/lib/valgrind/vgpreload_core-amd64-linux.so --21189-- Considering /usr/lib/valgrind/vgpreload_core-amd64-linux.so .. --21189-- .. CRC mismatch (computed a30c8eaa wanted 7ae2fed4) --21189-- object doesn't have a symbol table --21189-- Reading syms from /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so --21189-- Considering /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so .. --21189-- .. CRC mismatch (computed 402c2ab5 wanted 745f25ae) --21189-- object doesn't have a symbol table ==21189== WARNING: new redirection conflicts with existing -- ignoring it --21189-- old: 0x0401cdc0 (strlen ) R-> (0000.0) 0x3809e181 ??? --21189-- new: 0x0401cdc0 (strlen ) R-> (2007.0) 0x04c31020 strlen --21189-- REDIR: 0x401b710 (ld-linux-x86-64.so.2:index) redirected to 0x4c30bc0 (index) --21189-- REDIR: 0x401b930 (ld-linux-x86-64.so.2:strcmp) redirected to 0x4c320d0 (strcmp) --21189-- REDIR: 0x401db20 (ld-linux-x86-64.so.2:mempcpy) redirected to 0x4c35270 (mempcpy) --21189-- Reading syms from /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21 --21189-- Considering /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21 .. --21189-- .. CRC mismatch (computed 834c912e wanted c67ab13d) --21189-- object doesn't have a symbol table --21189-- Reading syms from /lib/x86_64-linux-gnu/libm-2.23.so --21189-- Considering /lib/x86_64-linux-gnu/libm-2.23.so .. --21189-- .. CRC mismatch (computed 3989a391 wanted dd37ef77) --21189-- Considering /usr/lib/debug/lib/x86_64-linux-gnu/libm-2.23.so .. --21189-- .. CRC is valid --21189-- Reading syms from /lib/x86_64-linux-gnu/libgcc_s.so.1 --21189-- Considering /lib/x86_64-linux-gnu/libgcc_s.so.1 .. --21189-- .. CRC mismatch (computed b9a68419 wanted 29d51b00) --21189-- object doesn't have a symbol table --21189-- Reading syms from /lib/x86_64-linux-gnu/libc-2.23.so --21189-- Considering /lib/x86_64-linux-gnu/libc-2.23.so .. --21189-- .. CRC mismatch (computed f3344b67 wanted 8e4ae80b) --21189-- Considering /usr/lib/debug/lib/x86_64-linux-gnu/libc-2.23.so .. --21189-- .. CRC is valid --21189-- REDIR: 0x5769e50 (libc.so.6:strcasecmp) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper) --21189-- REDIR: 0x57656d0 (libc.so.6:strcspn) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper) --21189-- REDIR: 0x576c140 (libc.so.6:strncasecmp) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper) --21189-- REDIR: 0x5767b40 (libc.so.6:strpbrk) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper) --21189-- REDIR: 0x5767ed0 (libc.so.6:strspn) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper) --21189-- REDIR: 0x576959b (libc.so.6:memcpy@GLIBC_2.2.5) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper) --21189-- REDIR: 0x5767850 (libc.so.6:rindex) redirected to 0x4c308a0 (rindex) --21189-- REDIR: 0x575e580 (libc.so.6:malloc) redirected to 0x4c2db20 (malloc) --21189-- REDIR: 0x5765b70 (libc.so.6:strlen) redirected to 0x4c30f60 (strlen) --21189-- REDIR: 0x5769040 (libc.so.6:__GI_memcmp) redirected to 0x4c33b90 (__GI_memcmp) --21189-- REDIR: 0x5764120 (libc.so.6:strcmp) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper) --21189-- REDIR: 0x57799c0 (libc.so.6:__strcmp_sse2_unaligned) redirected to 0x4c31f90 (strcmp) --21189-- REDIR: 0x4ec7e60 (libstdc++.so.6:operator new(unsigned long)) redirected to 0x4c2e080 (operator new(unsigned long)) --21189-- REDIR: 0x575f160 (libc.so.6:calloc) redirected to 0x4c2faa0 (calloc) --21189-- REDIR: 0x57655b0 (libc.so.6:strcpy) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper) --21189-- REDIR: 0x577fe20 (libc.so.6:__strcpy_sse2_unaligned) redirected to 0x4c31040 (strcpy) --21189-- REDIR: 0x575e940 (libc.so.6:free) redirected to 0x4c2ed80 (free) --21189-- REDIR: 0x5768a80 (libc.so.6:strstr) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper) --21189-- REDIR: 0x57844c0 (libc.so.6:__strstr_sse2_unaligned) redirected to 0x4c35460 (strstr) --21189-- REDIR: 0x5769800 (libc.so.6:__GI_mempcpy) redirected to 0x4c34fa0 (__GI_mempcpy) --21189-- REDIR: 0x5770bb0 (libc.so.6:strchrnul) redirected to 0x4c34da0 (strchrnul) [doctest] doctest version is "1.1.3" [doctest] run with "--help" for options --21189-- REDIR: 0x5827dc0 (libc.so.6:__memmove_avx_unaligned) redirected to 0x4c32230 (memcpy@GLIBC_2.2.5) --21189-- REDIR: 0x4ec5f10 (libstdc++.so.6:operator delete(void*)) redirected to 0x4c2f1e0 (operator delete(void*)) --21189-- REDIR: 0x576e8c0 (libc.so.6:__GI_memcpy) redirected to 0x4c32b00 (__GI_memcpy) --21189-- REDIR: 0x5769000 (libc.so.6:bcmp) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper) --21189-- REDIR: 0x5848840 (libc.so.6:__memcmp_sse4_1) redirected to 0x4c33cd0 (__memcmp_sse4_1) --21189-- REDIR: 0x576e840 (libc.so.6:memcpy@@GLIBC_2.14) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper) --21189-- REDIR: 0x58282b0 (libc.so.6:__memcpy_avx_unaligned) redirected to 0x4c324a0 (memcpy@@GLIBC_2.14) --21189-- REDIR: 0x5768cb0 (libc.so.6:memchr) redirected to 0x4c32170 (memchr) --21189-- REDIR: 0x575eb10 (libc.so.6:realloc) redirected to 0x4c2fce0 (realloc) --21189-- REDIR: 0x5769600 (libc.so.6:memset) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper) --21189-- REDIR: 0x584cd80 (libc.so.6:__memset_avx2) redirected to 0x4c344c0 (memset) vex amd64->IR: unhandled instruction bytes: 0xF 0xC7 0xF0 0x89 0x6 0xF 0x42 0xC1 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=0F vex amd64->IR: PFX.66=0 PFX.F2=0 PFX.F3=0 ==21189== valgrind: Unrecognised instruction at address 0x4ef1b15. ==21189== at 0x4EF1B15: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21) ==21189== by 0x4EF1CB1: std::random_device::_M_getval() (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21) ==21189== by 0x4EF36A: operator() (random.h:1612) ==21189== by 0x4EF36A: _DOCTEST_ANON_FUNC_33() (convolution.cpp:407) ==21189== by 0x405BD1: doctest::detail::callTestFunc(void (*)()) (doctest.h:2604) ==21189== by 0x40DB46: doctest::Context::run() (doctest.h:3353) ==21189== by 0x40E5C2: main (doctest.h:3446) ==21189== Your program just tried to execute an instruction that Valgrind ==21189== did not recognise. There are two possible reasons for this. ==21189== 1. Your program has a bug and erroneously jumped to a non-code ==21189== location. If you are running Memcheck and you just saw a ==21189== warning about a bad jump, it's probably your program's fault. ==21189== 2. The instruction is legitimate but Valgrind doesn't handle it, ==21189== i.e. it's Valgrind's fault. If you think this is the case or ==21189== you are not sure, please let us know and we'll try to fix it. ==21189== Either way, Valgrind will now raise a SIGILL signal which will ==21189== probably kill your program. ==21189== ==21189== Process terminating with default action of signal 4 (SIGILL) ==21189== Illegal opcode at address 0x4EF1B15 ==21189== at 0x4EF1B15: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21) ==21189== by 0x4EF1CB1: std::random_device::_M_getval() (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21) ==21189== by 0x4EF36A: operator() (random.h:1612) ==21189== by 0x4EF36A: _DOCTEST_ANON_FUNC_33() (convolution.cpp:407) ==21189== by 0x405BD1: doctest::detail::callTestFunc(void (*)()) (doctest.h:2604) ==21189== by 0x40DB46: doctest::Context::run() (doctest.h:3353) ==21189== by 0x40E5C2: main (doctest.h:3446) ==21189== ==21189== HEAP SUMMARY: ==21189== in use at exit: 81,181 bytes in 36 blocks ==21189== total heap usage: 3,605 allocs, 3,569 frees, 156,455 bytes allocated ==21189== ==21189== Searching for pointers to 36 not-freed blocks ==21189== Checked 119,792 bytes ==21189== ==21189== LEAK SUMMARY: ==21189== definitely lost: 0 bytes in 0 blocks ==21189== indirectly lost: 0 bytes in 0 blocks ==21189== possibly lost: 0 bytes in 0 blocks ==21189== still reachable: 81,181 bytes in 36 blocks ==21189== suppressed: 0 bytes in 0 blocks ==21189== Rerun with --leak-check=full to see details of leaked memory ==21189== ==21189== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) ==21189== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) zsh: illegal hardware instruction (core dumped) valgrind -v ./unit_tests
*** This bug has been marked as a duplicate of bug 353370 ***