This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Threadsafe exception handling needed even if no exceptions used?
- To: egcs at cygnus dot com, wmglo at dent dot med dot uni-muenchen dot de
- Subject: Re: Threadsafe exception handling needed even if no exceptions used?
- From: mrs at wrs dot com (Mike Stump)
- Date: Mon, 28 Dec 1998 15:03:54 -0800
> Date: 28 Dec 1998 15:25:37 -0000
> From: Wolfram Gloger <wmglo@dent.med.uni-muenchen.de>
> To: egcs@cygnus.com
> I think I've just tracked down a very erratic bug in one of my
> programs, which only appears on Irix6 with egcs-1.0.3 -- on Linux
> everything was/is fine, even with the `old' egcs-1.0.3. Now I'd like
> to confirm the possible cause before upgrading to 1.1.1.
> I'm using threads from C++, but no exceptions (though I have _not_
> compiled all my code with `-fno-exceptions').
> It seems that after creating a thread from a C++ function f(), very
> rarely the content of __dynamic_handler_chain gets corrupted by the
> created subthread, which leads to a crash in f(), even though no
> exceptions are ever thrown or caught anywhere in the code.
> I'd just like to confirm whether this explanation is plausible.
> For bonus points, would consistently specifying `-fno-exceptions'
> everywhere help?,
Yes.
> and why does it only seem to happen on Irix
I bet it uses setjmp/longjmp EH, and linux doesn't.
> (I thought the exception handling was identical on Linux/all ELF
> platforms) ?
No, they are probably not identical. Either use -fno-exceptions, or
don't use multiple threads or use a snapshot later than:
Mon Nov 23 20:28:02 1998 Mike Stump <mrs@wrs.com>
* libgcc2.c (top_elt): Remove top_elt, it isn't thread safe.
The strategy we now use is to pre allocate the top_elt along
with the EH context so that each thread has its own top_elt.
This is necessary as the dynmanic cleanup chain is used on the
top element of the stack and each thread MUST have its own.
(eh_context_static): Likewise.
(new_eh_context): Likewise.
(__sjthrow): Likewise.