SIGTRAP during thr_new syscall

Amol Dixit dixit at
Wed Sep 24 21:34:14 UTC 2008

I am seeing an unexpected SIGTRAP being reported to gdbserver when the 
debugged process creates a new thread via the _pthread_create() call of 
libthr library.  [libthr/thread/thr_create.c,v, Freebsd 6.0]
Gdbserver has internally set a breakpoint on address of 
_thread_bp_create() so that it gets notified on thread creation and is 
expecting a SIGTRAP at address (stop pc) of _thread_bp_create(). But 
instead SIGTRAP happens as a side-effect of thr_new() system call and 
the stop pc at that point is that of routine thread_start() which is the 
starting function of new thread. So gdbserver cannot match expected 
breakpoint (ie. _thread_bp_create) and is confused.
For testing purpose, if I call _thread_bp_create() before thr_new() in 
_pthread_create(), I get the _expected_ SIGTRAP with address of 
_thread_bp_create. But that is not the fix.
Does anyone have any idea about this SIGTRAP being reported to tracing 
process gdbserver as part of thr_new? Where is it originating from and why?

More information about the freebsd-threads mailing list