This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
setjmp() shares a single jmp_buf across all threads
- From: Andrew Haley <aph at cambridge dot redhat dot com>
- To: Adam Megacz <gcj at lists dot megacz dot com>
- Cc: java at gcc dot gnu dot org
- Date: Mon, 14 Jan 2002 18:30:12 +0000 (GMT)
- Subject: setjmp() shares a single jmp_buf across all threads
- References: <868zb0df4x.fsf@megacz.com>
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.