This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
EH_ALLOC_SIZE is not large enough
- To: gcc-patches at gcc dot gnu dot org
- Subject: EH_ALLOC_SIZE is not large enough
- From: Alexandre Oliva <aoliva at redhat dot com>
- Date: 24 Mar 2001 20:42:34 -0300
- Cc: nathan at codesourcery dot com
- Organization: GCC Team, Red Hat
g++.old-deja/g++.eh/g+.eh/badalloc1.C fails on machines with 64-bit
pointers and longs. The problem occurs when attempting to throw a new
exception in fn_catchthrow(), while handling the previously-thrown
integer. The alloc_buffer in the eh_context was allocated like this:
16 bytes (4 + padding) for the initially thrown integer
16 bytes left unused, separating memory chunks
80 bytes (72 + padding) for the cp_eh_info of that integer
16 bytes left unused, separating memory chunks
16 bytes (4 + padding) for the newly-thrown integer
16 bytes left unused, separating memory chunks
80 bytes (72 + padding) for the cp_eh_info of the new integer
---
240
192 is clearly not enough.
It appears to me that modifying EH_ALLOC_SIZE is an ABI change, so I'd
rather change it sooner than later.
Ok to install?
On a side note, I don't understand how the test is supposed to
accomplish what it says: it seems to attempt to check that bad_alloc
can be thrown in out-of-memory situations, but bad_alloc is never
thrown during the execution of this test. Nathan?
Index: gcc/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* eh-common.h (EH_ALLOC_SIZE): Bump to 240.
Index: gcc/eh-common.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/eh-common.h,v
retrieving revision 1.13
diff -u -p -r1.13 eh-common.h
--- gcc/eh-common.h 2000/07/22 23:29:14 1.13
+++ gcc/eh-common.h 2001/03/24 23:32:24
@@ -1,5 +1,5 @@
/* EH stuff
- Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of GNU CC.
@@ -40,10 +40,13 @@ Foundation, 59 Temple Place - Suite 330,
the location of 'dynamic_handler_chain'. If its location is changed,
that routine must be modified as well. */
#ifndef EH_ALLOC_SIZE
-/* 192 bytes means the entire eh_context plus malloc overhead fits in 256
- bytes (assuming 8 byte pointers). 192 bytes gives an eh_info and object
- size limit of 96 bytes. This should be sufficient for throwing bad_alloc. */
-#define EH_ALLOC_SIZE 192
+/* 240 bytes are required in the worst case, assuming pointers and
+ longs are 64-bits wide. When re-throwing an exception whose size
+ is smaller than EH_ALLOC_ALIGN, two cp_eh_info plus two copies of
+ the exception object must be held, in addition to the
+ EH_ALLOC_ALIGN padding between them. This should be sufficient for
+ throwing bad_alloc. */
+#define EH_ALLOC_SIZE 240
#endif
#ifndef EH_ALLOC_ALIGN
/* We can't use BIGGEST_ALIGNMENT, because on some systems, that expands to
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist *Please* write to mailing lists, not to me