Bug 385477 - AMD64, sqlite3 - Unrecognised instruction: bextr
Summary: AMD64, sqlite3 - Unrecognised instruction: bextr
Status: RESOLVED DUPLICATE of bug 381819
Alias: None
Product: valgrind
Classification: Developer tools
Component: vex (show other bugs)
Version: 3.14 SVN
Platform: Other Linux
: NOR major
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-07 22:50 UTC by nuquaquaraqua
Modified: 2020-12-27 21:04 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 nuquaquaraqua 2017-10-07 22:50:26 UTC
Valgrind aborts with the following error message:

==13490== 
vex amd64->IR: unhandled instruction bytes: 0x8F 0xE9 0xF8 0x97 0x5 0x6D 0x4E 0xD 0x0 0xC5
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
==6034== valgrind: Unrecognised instruction at address 0x1a75fa.
==6034==    at 0x1A75FA: unixOpen (sqlite3.c:36160)
==6034==    by 0x1BE20E: sqlite3OsOpen (sqlite3.c:20823)
==6034==    by 0x1BE20E: sqlite3PagerOpen (sqlite3.c:52236)
==6034==    by 0x1BE20E: sqlite3BtreeOpen (sqlite3.c:61903)
==6034==    by 0x1D6374: openDatabase (sqlite3.c:144562)

According to objdump, that area corresponds to:

   9f5fa:	8f ea f8 10 c9 03 1d 	bextr  $0x1d03,%rcx,%rcx
   9f601:	00 00 
   9f603:	f3 48 ab             	rep stos %rax,%es:(%rdi)

The source code is sqlite3.c, v.3.20.1, "amalgamated" ( https://www.sqlite.org/download.html)

Compiled with:
gcc -c  -DNDEBUG -g -fno-omit-frame-pointer -Wall -O3 -march=native -mtune=native -fno-stack-protector ../third-party/sqlite3/sqlite3.c -o objects/third-party/sqlite3/sqlite3.o 

Platform: AMD FX-8350 on ArchLinux 64-bit, gcc 7.2, same problem with clang 5.0
Tip of valgrind, from git, at 856d45eb7e3661a61ace32be2cfa10bf198620c8, but the problem is also present in at least v3.13.
Comment 1 nuquaquaraqua 2017-10-07 23:11:24 UTC
Hey, a similar instruction causes an abort from the C++ stdlib <random>, using mt19937_64: 

vex amd64->IR: unhandled instruction bytes: 0x8F 0xEA 0xF8 0x10 0xC7 0x3 0x1 0x0 0x0 0x48
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
==7233== valgrind: Unrecognised instruction at address 0x139ef0.
==7233==    at 0x139EF0: std::mersenne_twister_engine<unsigned long, 64ul, 312ul, 156ul, 31ul, 13043109905998158313ul, 29ul, 6148914691236517205ul, 17ul, 8202884508482404352ul, 37ul, 18444473444759240704ul, 43ul, 6364136223846793005ul>::operator()() (random.tcc:469)
==7233==    by 0x13E7A7: operator()<std::mersenne_twister_engine<long unsigned int, 64, 312, 156, 31, 13043109905998158313, 29, 6148914691236517205, 17, 8202884508482404352, 37, 18444473444759240704, 43, 6364136223846793005> > (uniform_int_dist.h:246)
==7233==    by 0x13E7A7: operator()<std::mersenne_twister_engine<long unsigned int, 64, 312, 156, 31, 13043109905998158313, 29, 6148914691236517205, 17, 8202884508482404352, 37, 18444473444759240704, 43, 6364136223846793005> > (uniform_int_dist.h:169)
Comment 2 Mark Wielaard 2017-10-08 11:45:03 UTC
The BMI bextr instruction is supposed to be handled, but apparently not this variant. See also https://bugs.kde.org/show_bug.cgi?id=381819
Comment 3 Mark Wielaard 2020-12-27 21:04:48 UTC

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