From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1571) id 122183858D38; Thu, 22 Sep 2022 23:26:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 122183858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663889210; bh=DAhXPQvItz3Z/WmH78ZPt2DNYis0LbLUPJ+j04wf3yE=; h=From:To:Subject:Date:From; b=Y6kqd9BDMBKOwdp/Cd8GGbP6hFLeLno8ygZgUkv1d57hx5Z3ht04lWHxkgScklRqJ hkYq9y8lehME6KDVOpsv0VxMcQI5+jBjeA3gU2gYTmU4sihZQahEjqUygLpK0MbEam 7mOVWvr3ldRe9fxYToaI6Pg8EstpvSmDH6GXivhw= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Thomas Neumann To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-2801] Avoid depending on destructor order X-Act-Checkin: gcc X-Git-Author: Thomas Neumann X-Git-Refname: refs/heads/master X-Git-Oldrev: 32524808fad7dc753b177f6c2f2e4cdc7e82f3c3 X-Git-Newrev: 94ccaf62c378c3737f7e4b6a80e1160157119171 Message-Id: <20220922232650.122183858D38@sourceware.org> Date: Thu, 22 Sep 2022 23:26:50 +0000 (GMT) List-Id: https://gcc.gnu.org/g:94ccaf62c378c3737f7e4b6a80e1160157119171 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. libgcc/ChangeLog: * unwind-dw2-fde.c: (release_register_frames) Remember when the btree has been destroyed. (__deregister_frame_info_bases) Disable the assert when shutting down. Diff: --- 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 (®istered_frames); + in_shutdown = true; } static void @@ -282,7 +284,7 @@ __deregister_frame_info_bases (const void *begin) __gthread_mutex_unlock (&object_mutex); #endif - gcc_assert (ob); + gcc_assert (in_shutdown || ob); return (void *) ob; }