protecting __deregister_frame_info

Gavin Romig-Koch gavin@cygnus.com
Wed Oct 13 14:27:00 GMT 1999


OK to commit?

__do_global_dtors can get called multiple times if a destructor,
or atexit, function calls exit again.  While the standard says calling
exit twice is undefined, we already do this protection for destructors, so
this patch does it for __deregister_frame_info too.

(Also, the current mips embedded targets are registering do_global_dtors
twice with atexit, which causes __do_global_dtors to be called twice.
This is wrong, but I haven't figured out how to fix it yet.)

                                                -gavin...


	* libgcc2.c (__do_global_dtors): Protect __deregister_frame_info
	from multiple calls.

Index: libgcc2.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/libgcc2.c,v
retrieving revision 1.74
diff -u -p -r1.74 libgcc2.c
--- libgcc2.c	1999/10/05 19:59:03	1.74
+++ libgcc2.c	1999/10/13 21:16:51
@@ -2867,7 +2867,14 @@ __do_global_dtors ()
     }
 #endif
 #ifdef EH_FRAME_SECTION
-  __deregister_frame_info (__EH_FRAME_BEGIN__);
+  {
+    static int completed = 0;
+    if (! completed)
+      {
+	__deregister_frame_info (__EH_FRAME_BEGIN__);
+	completed = 1;
+      }
+  }
 #endif
 }
 #endif


More information about the Gcc-patches mailing list