public inbox for
help / color / mirror / Atom feed
* [gcc r13-2801] Avoid depending on destructor order
@ 2022-09-22 23:26 Thomas Neumann
  0 siblings, 0 replies; only message in thread
From: Thomas Neumann @ 2022-09-22 23:26 UTC (permalink / raw)
  To: gcc-cvs

commit r13-2801-g94ccaf62c378c3737f7e4b6a80e1160157119171
Author: Thomas Neumann <>
Date:   Mon Sep 19 18:10:02 2022 +0200

    Avoid depending on destructor order
    In some scenarios (e.g., when mixing gcc and clang code), it can
    happen that frames are deregistered after the lookup structure
    has already been destroyed. That in itself would be fine, but
    it triggers an assert in __deregister_frame_info_bases that
    expects to find the frame.
    To avoid that, we now remember that the btree as already been
    destroyed and disable the assert in that case.
            * unwind-dw2-fde.c: (release_register_frames) Remember
            when the btree has been destroyed.
            (__deregister_frame_info_bases) Disable the assert when
            shutting down.

 libgcc/unwind-dw2-fde.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libgcc/unwind-dw2-fde.c b/libgcc/unwind-dw2-fde.c
index 919abfe0664..d237179f4ea 100644
--- a/libgcc/unwind-dw2-fde.c
+++ b/libgcc/unwind-dw2-fde.c
@@ -48,6 +48,7 @@ typedef __UINTPTR_TYPE__ uintptr_type;
 #include "unwind-dw2-btree.h"
 static struct btree registered_frames;
+static bool in_shutdown;
 static void
 release_registered_frames (void) __attribute__ ((destructor (110)));
@@ -57,6 +58,7 @@ release_registered_frames (void)
   /* Release the b-tree and all frames. Frame releases that happen later are
    * silently ignored */
   btree_destroy (&registered_frames);
+  in_shutdown = true;
 static void
@@ -282,7 +284,7 @@ __deregister_frame_info_bases (const void *begin)
   __gthread_mutex_unlock (&object_mutex);
-  gcc_assert (ob);
+  gcc_assert (in_shutdown || ob);
   return (void *) ob;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-09-22 23:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-22 23:26 [gcc r13-2801] Avoid depending on destructor order Thomas Neumann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).