setjmp() shares a single jmp_buf across all threads
Andrew Haley
aph@cambridge.redhat.com
Mon Jan 14 10:30:00 GMT 2002
Adam Megacz writes:
>
> I figured out why exceptions and threads don't cooperate on win32 --
> it seems that a single jmp_buf is being used for all calls to setjmp(),
> instead of a different buffer for each thread.
Looks like gcc doesn't know about your threads package.
I think the jmp_buf is on the stack, but there's a thread-specific
object poiting to a chain of jmp_bufs.
Look in gcc/unwind-sjlj.c. See:
void
_Unwind_SjLj_Register (struct SjLj_Function_Context *fc)
{
#if __GTHREADS
if (use_fc_key < 0)
fc_key_init_once ();
if (use_fc_key)
{
fc->prev = __gthread_getspecific (fc_key);
__gthread_setspecific (fc_key, fc);
}
else
#endif
{
fc->prev = fc_static;
fc_static = fc;
}
}
You need to provide some local way of getting/setting thread-specific
data. I reckon if you fix this, everything will "just work". :-)
> Unfortunately, I can't seem to find where the calls to setjmp() are --
> I guess they're not in libjava. Is this one of those things that gcc
> handles? If so, can anybody tell me where to start looking?
See sjlj_emit_function_enter.
Andrew.
More information about the Java
mailing list