This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

setjmp() shares a single jmp_buf across all threads


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]