Mihai Donțu mihai.dontu at
Mon Oct 8 12:03:38 PDT 2007


I have a "small" amd64 program that makes havy use of LDT (%GS to be more
specific). The trouble is, in a multithreaded environment, the selector
value gets lost (or reset?).

The code *always* segfaults with this stack:
  4 LWP 100126  0x0000000800dec07c in select () from /lib/
* 3 Thread 0x517000 (runnable)  0x000000080055cfbc in ?? ()
  2 Thread 0x517400 (LWP 100125)  0x0000000800c0d85c in pthread_testcancel () from /lib/
  1 Thread 0x517800 (runnable)  0x0000000800d5d000 in makecontext () from /lib/

at this instruction:
  0x000000080055cfbc:     mov    %gs:0x10,%r11

  (gdb) p $gs
  $1 = 0

I've been reading on the net something about the kernel not preserving the GS
across syscalls (or stmh). Is this true? and if so, is there a known workaround?

I'm on a FreeBSD 6.2-STABLE-200706 (AMD64) machine.


Mihai Donțu

More information about the freebsd-questions mailing list