Bug 183409 - Valgrind does not support instructions sgdtq (x86_64) and sgdtl (x86)
Summary: Valgrind does not support instructions sgdtq (x86_64) and sgdtl (x86)
Alias: None
Product: valgrind
Classification: Developer tools
Component: vex (show other bugs)
Version: 3.4 SVN
Platform: Compiled Sources Linux
: NOR crash
Target Milestone: ---
Assignee: Julian Seward
Depends on:
Blocks: 256630
  Show dependency treegraph
Reported: 2009-02-06 11:38 UTC by Konstantin Serebryany
Modified: 2011-08-11 13:51 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Note You need to log in before you can comment on or make changes to this bug.
Description Konstantin Serebryany 2009-02-06 11:38:24 UTC
The following code will fail under valgrind like this: 
vex x86->IR: unhandled instruction bytes: 0xF 0x1 0x45 0xDE

#include <iostream>
#include <pthread.h>
// Compile and run:
// g++ -m64 sgdtq.cc -lpthread && valgrind  ./a.out
void *sgdtq(void *) {
 char ret_val[16] __attribute__((__aligned__(16)));
 // valgrind will fail here:
 __asm__ __volatile__("sgdtq %0" : "=m" (ret_val[6])::"memory");
 uint64_t id =  *reinterpret_cast<uint64_t *>(&ret_val[8]);
 std::cout << id << std::endl;

int main() {
 const int N = 100;
 pthread_t t[N];
 // start many threads. On a multi-cpu machine
 // this progam should print several different numbers.
 for (int i = 0; i < N; i++) {
   pthread_create(&t[i], 0, sgdtq, 0);
 for (int i = 0; i < N; i++) {
   pthread_join(t[i], 0);
Comment 1 Tom Hughes 2011-08-11 13:48:31 UTC
I'm a bit confused - the error you quote is "vex x86->IR" which suggests you are running 32 bit code but the test program says to compile as 64 bit, and indeed it won't compile as 32 bit because gcc says that the "sgdt" instruction is not recognised.
Comment 2 Tom Hughes 2011-08-11 13:51:15 UTC
Well it compiles and runs OK as 64 bit anyway, and as 32 bit after the q suffix is dropped from that instruction.

Looks like VEX r1982 fixed it.