Bug 375845 - Unrecognised instruction using std::random_device
Summary: Unrecognised instruction using std::random_device
Status: RESOLVED DUPLICATE of bug 353370
Alias: None
Product: valgrind
Classification: Developer tools
Component: memcheck (show other bugs)
Version: 3.11.0
Platform: Other Unspecified
: NOR crash
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-02-01 15:36 UTC by Colin Chambers
Modified: 2017-02-01 15:53 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Colin Chambers 2017-02-01 15:36:51 UTC
Full text of program is:
#include <iostream>
  using std::cout;

#include <random>
  using std::random_device;

int main()
{
    random_device random_seeder;
    cout << "number is " << random_seeder() << "\n";

    return 0;
}

uname -a
Linux colin-Precision-Tower-3620 4.4.0-42-generic #62-Ubuntu SMP Fri Oct 7 23:11:45 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Valgrind command line:
valgrind --read-inline-info=yes --log-file=valgrind.out -v ./random

Contents of valgrind.out:
==30058== Memcheck, a memory error detector
==30058== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==30058== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==30058== Command: ./random
==30058== Parent PID: 28615
==30058== 
--30058-- 
--30058-- Valgrind options:
--30058--    --read-inline-info=yes
--30058--    --log-file=valgrind.out
--30058--    -v
--30058-- Contents of /proc/version:
--30058--   Linux version 4.4.0-42-generic (buildd@lgw01-13) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.2) ) #62-Ubuntu SMP Fri Oct 7 23:11:45 UTC 2016
--30058-- 
--30058-- Arch and hwcaps: AMD64, LittleEndian, amd64-cx16-lzcnt-rdtscp-sse3-avx-avx2-bmi
--30058-- Page sizes: currently 4096, max supported 4096
--30058-- Valgrind library directory: /usr/lib/valgrind
--30058-- Reading syms from /media/big/colin/projects/c++-play/random-device/random
--30058-- Reading syms from /lib/x86_64-linux-gnu/ld-2.23.so
--30058--   Considering /lib/x86_64-linux-gnu/ld-2.23.so ..
--30058--   .. CRC mismatch (computed d3da0723 wanted a1c29704)
--30058--   Considering /usr/lib/debug/lib/x86_64-linux-gnu/ld-2.23.so ..
--30058--   .. CRC is valid
--30058-- Reading syms from /usr/lib/valgrind/memcheck-amd64-linux
--30058--   Considering /usr/lib/valgrind/memcheck-amd64-linux ..
--30058--   .. CRC mismatch (computed 5529a2c7 wanted 5bd23904)
--30058--    object doesn't have a symbol table
--30058--    object doesn't have a dynamic symbol table
--30058-- Scheduler: using generic scheduler lock implementation.
--30058-- Reading suppressions file: /usr/lib/valgrind/default.supp
==30058== embedded gdbserver: reading from /tmp/vgdb-pipe-from-vgdb-to-30058-by-colin-on-???
==30058== embedded gdbserver: writing to   /tmp/vgdb-pipe-to-vgdb-from-30058-by-colin-on-???
==30058== embedded gdbserver: shared mem   /tmp/vgdb-pipe-shared-mem-vgdb-30058-by-colin-on-???
==30058== 
==30058== TO CONTROL THIS PROCESS USING vgdb (which you probably
==30058== don't want to do, unless you know exactly what you're doing,
==30058== or are doing some strange experiment):
==30058==   /usr/lib/valgrind/../../bin/vgdb --pid=30058 ...command...
==30058== 
==30058== TO DEBUG THIS PROCESS USING GDB: start GDB like this
==30058==   /path/to/gdb ./random
==30058== and then give GDB the following command
==30058==   target remote | /usr/lib/valgrind/../../bin/vgdb --pid=30058
==30058== --pid is optional if only one valgrind process is running
==30058== 
--30058-- REDIR: 0x401cdc0 (ld-linux-x86-64.so.2:strlen) redirected to 0x3809e181 (???)
--30058-- Reading syms from /usr/lib/valgrind/vgpreload_core-amd64-linux.so
--30058--   Considering /usr/lib/valgrind/vgpreload_core-amd64-linux.so ..
--30058--   .. CRC mismatch (computed a30c8eaa wanted 7ae2fed4)
--30058--    object doesn't have a symbol table
--30058-- Reading syms from /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so
--30058--   Considering /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so ..
--30058--   .. CRC mismatch (computed 402c2ab5 wanted 745f25ae)
--30058--    object doesn't have a symbol table
==30058== WARNING: new redirection conflicts with existing -- ignoring it
--30058--     old: 0x0401cdc0 (strlen              ) R-> (0000.0) 0x3809e181 ???
--30058--     new: 0x0401cdc0 (strlen              ) R-> (2007.0) 0x04c31020 strlen
--30058-- REDIR: 0x401b710 (ld-linux-x86-64.so.2:index) redirected to 0x4c30bc0 (index)
--30058-- REDIR: 0x401b930 (ld-linux-x86-64.so.2:strcmp) redirected to 0x4c320d0 (strcmp)
--30058-- REDIR: 0x401db20 (ld-linux-x86-64.so.2:mempcpy) redirected to 0x4c35270 (mempcpy)
--30058-- Reading syms from /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
--30058--   Considering /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21 ..
--30058--   .. CRC mismatch (computed 834c912e wanted c67ab13d)
--30058--    object doesn't have a symbol table
--30058-- Reading syms from /lib/x86_64-linux-gnu/libgcc_s.so.1
--30058--   Considering /lib/x86_64-linux-gnu/libgcc_s.so.1 ..
--30058--   .. CRC mismatch (computed b9a68419 wanted 29d51b00)
--30058--    object doesn't have a symbol table
--30058-- Reading syms from /lib/x86_64-linux-gnu/libc-2.23.so
--30058--   Considering /lib/x86_64-linux-gnu/libc-2.23.so ..
--30058--   .. CRC mismatch (computed 2adb2e50 wanted 9b73f606)
--30058--   Considering /usr/lib/debug/lib/x86_64-linux-gnu/libc-2.23.so ..
--30058--   .. CRC is valid
--30058-- Reading syms from /lib/x86_64-linux-gnu/libm-2.23.so
--30058--   Considering /lib/x86_64-linux-gnu/libm-2.23.so ..
--30058--   .. CRC mismatch (computed f7791cb7 wanted 92acf4be)
--30058--   Considering /usr/lib/debug/lib/x86_64-linux-gnu/libm-2.23.so ..
--30058--   .. CRC is valid
--30058-- REDIR: 0x5460fd0 (libc.so.6:strcasecmp) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--30058-- REDIR: 0x545c850 (libc.so.6:strcspn) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--30058-- REDIR: 0x54632c0 (libc.so.6:strncasecmp) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--30058-- REDIR: 0x545ecc0 (libc.so.6:strpbrk) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--30058-- REDIR: 0x545f050 (libc.so.6:strspn) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--30058-- REDIR: 0x546071b (libc.so.6:memcpy@GLIBC_2.2.5) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--30058-- REDIR: 0x545e9d0 (libc.so.6:rindex) redirected to 0x4c308a0 (rindex)
--30058-- REDIR: 0x5455550 (libc.so.6:malloc) redirected to 0x4c2db20 (malloc)
--30058-- REDIR: 0x545ccf0 (libc.so.6:strlen) redirected to 0x4c30f60 (strlen)
--30058-- REDIR: 0x54601c0 (libc.so.6:__GI_memcmp) redirected to 0x4c33b90 (__GI_memcmp)
--30058-- REDIR: 0x545b2a0 (libc.so.6:strcmp) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--30058-- REDIR: 0x5470b40 (libc.so.6:__strcmp_sse2_unaligned) redirected to 0x4c31f90 (strcmp)
--30058-- REDIR: 0x54659c0 (libc.so.6:memcpy@@GLIBC_2.14) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--30058-- REDIR: 0x551f6d0 (libc.so.6:__memcpy_avx_unaligned) redirected to 0x4c324a0 (memcpy@@GLIBC_2.14)
--30058-- REDIR: 0x5460180 (libc.so.6:bcmp) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--30058-- REDIR: 0x553fc60 (libc.so.6:__memcmp_sse4_1) redirected to 0x4c33cd0 (__memcmp_sse4_1)
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
==30058== valgrind: Unrecognised instruction at address 0x4ef1b15.
==30058==    at 0x4EF1B15: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
==30058==    by 0x4EF1CB1: std::random_device::_M_getval() (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
==30058==    by 0x400E49: std::random_device::operator()() (random.h:1612)
==30058==    by 0x400CF0: main (random.cpp:10)
==30058== Your program just tried to execute an instruction that Valgrind
==30058== did not recognise.  There are two possible reasons for this.
==30058== 1. Your program has a bug and erroneously jumped to a non-code
==30058==    location.  If you are running Memcheck and you just saw a
==30058==    warning about a bad jump, it's probably your program's fault.
==30058== 2. The instruction is legitimate but Valgrind doesn't handle it,
==30058==    i.e. it's Valgrind's fault.  If you think this is the case or
==30058==    you are not sure, please let us know and we'll try to fix it.
==30058== Either way, Valgrind will now raise a SIGILL signal which will
==30058== probably kill your program.
==30058== 
==30058== Process terminating with default action of signal 4 (SIGILL)
==30058==  Illegal opcode at address 0x4EF1B15
==30058==    at 0x4EF1B15: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
==30058==    by 0x4EF1CB1: std::random_device::_M_getval() (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
==30058==    by 0x400E49: std::random_device::operator()() (random.h:1612)
==30058==    by 0x400CF0: main (random.cpp:10)
--30058-- REDIR: 0x5455a70 (libc.so.6:free) redirected to 0x4c2ed80 (free)
==30058== 
==30058== HEAP SUMMARY:
==30058==     in use at exit: 72,704 bytes in 1 blocks
==30058==   total heap usage: 1 allocs, 0 frees, 72,704 bytes allocated
==30058== 
==30058== Searching for pointers to 1 not-freed blocks
==30058== Checked 115,632 bytes
==30058== 
==30058== LEAK SUMMARY:
==30058==    definitely lost: 0 bytes in 0 blocks
==30058==    indirectly lost: 0 bytes in 0 blocks
==30058==      possibly lost: 0 bytes in 0 blocks
==30058==    still reachable: 72,704 bytes in 1 blocks
==30058==         suppressed: 0 bytes in 0 blocks
==30058== Rerun with --leak-check=full to see details of leaked memory
==30058== 
==30058== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
==30058== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Comment 1 Tom Hughes 2017-02-01 15:53:09 UTC
That's an RDRAND instruction which should be fixed in 3.12.0 already.

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