This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
sjlj exception and malloc
- To: egcs at cygnus dot com
- Subject: sjlj exception and malloc
- From: Steven Parkes <parkes at sierravista dot com>
- Date: Thu, 15 Oct 1998 20:36:57 -0700
- Organization: Sierra Vista Research, Inc.
When using sjlj exceptions, malloc gets called very early in order to
allocate the static eh context. This is a real problem for us because
we implement our own malloc in C++. The result is infinite recursion.
Because there is only one of these static objects, it's straightforward
to statically allocate the object and then just do the initialization,
which breaks the loop. I've observed no negative side effects other
than the 12 bytes of data space that aren't used when eh_context_static
isn't used.
*** libgcc2.c.orig Mon Jul 6 16:52:21 1998
--- libgcc2.c Thu Oct 15 19:32:49 1998
***************
*** 3164,3185 ****
return (*get_eh_context) ();
}
/* Return a static EH context. */
static struct eh_context *
eh_context_static ()
{
static struct eh_context *eh;
! if (! eh)
! eh = new_eh_context ();
return eh;
}
#if __GTHREADS
/* Return a thread specific EH context. */
static struct eh_context *
eh_context_specific ()
{
struct eh_context *eh;
--- 3164,3189 ----
return (*get_eh_context) ();
}
/* Return a static EH context. */
static struct eh_context *
eh_context_static ()
{
static struct eh_context *eh;
! if (! eh) {
! static struct eh_context seh;
! eh = &seh;
! memset (eh, 0, sizeof *eh);
! eh->dynamic_handler_chain = top_elt;
! }
return eh;
}
#if __GTHREADS
/* Return a thread specific EH context. */
static struct eh_context *
eh_context_specific ()
{
struct eh_context *eh;