This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ patch]: Exception emergency space
- To: gcc-patches at gcc dot gnu dot org
- Subject: [C++ patch]: Exception emergency space
- From: Nathan Sidwell <nathan at codesourcery dot com>
- Date: Wed, 11 Apr 2001 11:16:09 +0100
- CC: rth at redhat dot com
- Organization: Codesourcery LLC
Hi,
I attach a patch for eh_alloc.cc which
1) checks the required size fits in the emergency size
2) doesn't call std::terminate holding the mutex.
built & tested on i686-pc-linux-gnu
ok?
nathan
--
Dr Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2001-04-11 Nathan Sidwell <nathan@codesourcery.com>
* libsupc++/eh_alloc.cc (__cxa_allocate_exception): Don't
terminate holding the mutex. Make sure size fits in EMERGENCY_OBJ_SIZE.
Index: libsupc++/eh_alloc.cc
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/libsupc++/eh_alloc.cc,v
retrieving revision 1.1
diff -c -3 -p -r1.1 eh_alloc.cc
*** eh_alloc.cc 2001/03/28 11:04:50 1.1
--- eh_alloc.cc 2001/04/11 09:50:34
*************** __cxa_allocate_exception(std::size_t thr
*** 113,131 ****
bitmask_type used = emergency_used;
unsigned int which = 0;
while (used & 1)
{
used >>= 1;
if (++which >= EMERGENCY_OBJ_COUNT)
! std::terminate ();
}
emergency_used |= (bitmask_type)1 << which;
ret = &emergency_buffer[which][0];
#ifdef __GTHREADS
__gthread_mutex_unlock (&emergency_mutex);
#endif
}
memset (ret, 0, sizeof (__cxa_exception));
--- 113,136 ----
bitmask_type used = emergency_used;
unsigned int which = 0;
+ if (thrown_size > EMERGENCY_OBJ_SIZE)
+ goto failed;
while (used & 1)
{
used >>= 1;
if (++which >= EMERGENCY_OBJ_COUNT)
! goto failed;
}
emergency_used |= (bitmask_type)1 << which;
ret = &emergency_buffer[which][0];
+ failed:;
#ifdef __GTHREADS
__gthread_mutex_unlock (&emergency_mutex);
#endif
+ if (!ret)
+ std::terminate ();
}
memset (ret, 0, sizeof (__cxa_exception));