setjmp() shares a single jmp_buf across all threads [fixed]
Adam Megacz
gcj@lists.megacz.com
Mon Jan 14 17:04:00 GMT 2002
Andrew Haley <aph@cambridge.redhat.com> writes:
> > > 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.
> I just realized that there's probably a misunderstanding here. It's
> not just that one function that needs fixing, but all those in the
> file that use thread calls.
Ah, thank you. I've found the problem, and it revolves around this
bizarreness in mingw:
/* Mingw runtime >= v0.3 provides a magic variable that is set to non-zero
if -mthreads option was specified, or 0 otherwise. This is to get around
the lack of weak symbols in PE-COFF. */
extern int _CRT_MT;
I've simply disabled the use of mingw_thr_dtor() for now, and
everything works nicely. Does anybody know what mingw_thr_dtor()
does/means? To the best of my knowledge, it is in charge of
automatically deallocating thread-local storage when a thread
terminates (why on earth doesn't Win32 do this?)
Since libjava never allocates more than a few bytes of TLS per thread,
this leak shouldn't be a problem in the short-term. I'll work on a
more elegant fix later.
- a
More information about the Java
mailing list