setjmp() shares a single jmp_buf across all threads

Adam Megacz
Mon Jan 14 13:14:00 GMT 2002

Andrew Haley <> writes:
> Looks like gcc doesn't know about your threads package.

Hrm, I configured with --enable-threads=win32...

> Look in gcc/unwind-sjlj.c.  See:
> void _Unwind_SjLj_Register (struct SjLj_Function_Context *fc)

This is completely bizarre; I put an infinite loop at the top of this
function, yet when I recompile/link/run programs that throw
exceptions, they don't hang.

After grepping through the source, I found that the symbol
_Unwind_SjLj_Register doesn't appear anywhere outside of
unwind-sjlj.c... where is this function called from?

> You need to provide some local way of getting/setting thread-specific
> data.  I reckon if you fix this, everything will "just work".  :-)

Yeah, gthr-win32.c defines an implementation (TlsSet/TlsGet) which
ought to work, I just don't think it's getting called.

Another question: what is the difference between the "builtin setjmp"
and the non-builtin setjmp? Does "builtin" mean that the compiler just
dumps out code to do setjmp's work instead of emitting a call to a
library function?

  - a

More information about the Java mailing list