This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: GC Bug
- To: richard dot earnshaw at arm dot com
- Subject: Re: GC Bug
- From: Bernd Schmidt <bernds at cygnus dot co dot uk>
- Date: Thu, 9 Sep 1999 14:48:14 +0100 (BST)
- cc: gcc-bugs at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
On Thu, 9 Sep 1999, Richard Earnshaw wrote:
> I'm trying to track down a GC problem on the ARM, which causes a crash.
> I've found the following fragment in except.c:
>
> static rtx
> call_get_eh_context ()
> {
> static tree fn;
> tree expr;
>
> if (fn == NULL_TREE)
> {
>
>
> Note that fn is persistent, but there seems to be no gc root registered
> for this when it is first allocated. Hence, the tree can get GCed later
> and if subsequently recalled can contain garbage.
Try this patch.
Bernd
* except.c (call_get_eh_context): Add root when allocating static
tree variable.
Index: except.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/except.c,v
retrieving revision 1.96
diff -u -p -r1.96 except.c
--- except.c 1999/09/09 07:17:20 1.96
+++ except.c 1999/09/09 13:45:50
@@ -1101,6 +1101,8 @@ call_get_eh_context ()
make_decl_rtl (fn, NULL_PTR, 1);
assemble_external (fn);
pop_obstacks ();
+
+ ggc_add_tree_root (&fn, 1);
}
expr = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (fn)), fn);