Message ID | 5aba5553-ed71-50a8-e934-6e94f3a1057e@in.tum.de |
---|---|
State | New, archived |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp1040800wrt; Mon, 19 Sep 2022 09:21:16 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5oyFo1wrz2NMYs3GhffQ5je091ci8wm8wkvOPjlc0Nnd6VRkYBUR1gCpFXxbWD7fdASJZe X-Received: by 2002:a05:6402:ca9:b0:44e:d8f3:3d0e with SMTP id cn9-20020a0564020ca900b0044ed8f33d0emr16189126edb.397.1663604476710; Mon, 19 Sep 2022 09:21:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663604476; cv=none; d=google.com; s=arc-20160816; b=OimoI5cCZPQj7xFyzZosnK2y047w7yIQvoRM550K777SCJRqbKCOu48ElIIefIG3Ud Eqs2padG1dTuGhm4j18mkTj3lPMAUD9L5NY0O/yDEdLLytAfT1iq0cq7yai/uuLgvoW6 /7JRVt4NV1a1/OMDyaEoeH+8Bq6Ug68DoAiAqbH9bxMchnAdW0y7RCrJFSda1iZy/vUn By2dFpkpewTA1xz2NR/7gKvOkpozzhxkqwYpXr9b8yRtCEjdVPS16yjJMAUmFBY6Ycer I21eGonLuhtP6+A9KWOn39/GdLmdG34hVUnyk8x/BnqEx+MwRKCqXeWlALbGboflN3ir Ay4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:subject:to:content-language:user-agent :mime-version:date:message-id:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=dmqUsclje1VbV714APZpkNWih8pLSA7QF947RT/QcTY=; b=ut0er1rXxEridhMv5fn13GKGGqxdkS7cOM+oE8BxOKn9ag5ROOU89xGpu1hDiFhuMR rYoSYSz95DkficGW/RuJ4aneClfBLekdlwW1UYEHXU5H56+TsYwW/ztTXrj6qdh4AWcm L5nMGL/zQeX7Cth+KyQ3HgY4Xp0KraOAofnPoku8BLeiPcdbdaMNj/jieLIRBAVokvhH tbDthz1ak0iOnVMF1TuHcgWSEuGHuDJ1G8ZX5Ew9ntj3VhypVTQ6uO9g8j7bxGQ0iT0k E9iu2twiaLlK6aeEXGcCQIzLdrCRbX5DbdkomZIohajlurAYVXHfBi73yKB/av6VB09I Jq0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=s5E3KB6q; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id q16-20020a1709064c9000b007314b427e96si21584331eju.633.2022.09.19.09.21.16 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 09:21:16 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=s5E3KB6q; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B06D33858C56 for <ouuuleilei@gmail.com>; Mon, 19 Sep 2022 16:21:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B06D33858C56 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663604475; bh=dmqUsclje1VbV714APZpkNWih8pLSA7QF947RT/QcTY=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=s5E3KB6qsb8MzlZXswCZoqc6T2TriPzFoznJoRM+Nnz3/MqdCcApZmQeTU41KZeZz Q2LLJ88NXSnqCrRBSETAy6BeARIXXy6WxgCtPScEJ+dX7QuAlEyA8K8LdqdwUQuY9S 2N1iTCNMa2Ob4HTCKWOiXrz8X4+uoBDk39BhOO/M= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mailout3.rbg.tum.de (mailout3.rbg.tum.de [131.159.0.8]) by sourceware.org (Postfix) with ESMTPS id 769023858D28 for <gcc-patches@gcc.gnu.org>; Mon, 19 Sep 2022 16:20:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 769023858D28 Received: from mailrelay1.rbg.tum.de (mailrelay1.in.tum.de [131.159.254.14]) by mailout3.rbg.tum.de (Postfix) with ESMTPS id 006D61003BD; Mon, 19 Sep 2022 18:20:23 +0200 (CEST) Received: by mailrelay1.rbg.tum.de (Postfix, from userid 112) id ECC9E1AA; Mon, 19 Sep 2022 18:20:23 +0200 (CEST) Received: from mailrelay1.rbg.tum.de (localhost [127.0.0.1]) by mailrelay1.rbg.tum.de (Postfix) with ESMTP id CA0B41A8; Mon, 19 Sep 2022 18:20:23 +0200 (CEST) Received: from mail.in.tum.de (mailproxy.in.tum.de [IPv6:2a09:80c0::78]) by mailrelay1.rbg.tum.de (Postfix) with ESMTPS id C813ACD; Mon, 19 Sep 2022 18:20:23 +0200 (CEST) Received: by mail.in.tum.de (Postfix, from userid 112) id C59584A034B; Mon, 19 Sep 2022 18:20:23 +0200 (CEST) Received: (Authenticated sender: neumann) by mail.in.tum.de (Postfix) with ESMTPSA id 89C1D4A0063; Mon, 19 Sep 2022 18:20:23 +0200 (CEST) (Extended-Queue-bit xtech_vi@fff.in.tum.de) Message-ID: <5aba5553-ed71-50a8-e934-6e94f3a1057e@in.tum.de> Date: Mon, 19 Sep 2022 18:20:23 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Content-Language: en-US To: gcc-patches@gcc.gnu.org Subject: [PATCH] Avoid depending on destructor order Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Thomas Neumann via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Thomas Neumann <neumann@in.tum.de> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1744415727563508919?= X-GMAIL-MSGID: =?utf-8?q?1744415727563508919?= |
Series |
Avoid depending on destructor order
|
|
Commit Message
Thomas Neumann
Sept. 19, 2022, 4:20 p.m. UTC
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. --- libgcc/unwind-dw2-fde.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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; }
Comments
On 9/19/22 12:20, Thomas Neumann wrote: > 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. OK. > 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. > --- > 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; > } >
Hi Thomas,
This change prohibits compiling of ARC backend:
> + gcc_assert (in_shutdown || ob);
in_shutdown is only defined when ATOMIC_FDE_FAST_PATH is defined,
while gcc_assert is outside of any ifdef. Please can you revisit this
line and change it accordingly.
Thanks,
Claudiu
Hi Claudiu, > This change prohibits compiling of ARC backend: > >> + gcc_assert (in_shutdown || ob); > > in_shutdown is only defined when ATOMIC_FDE_FAST_PATH is defined, > while gcc_assert is outside of any ifdef. Please can you revisit this > line and change it accordingly. I have a patch ready, I am waiting for someone to approve my patch: https://gcc.gnu.org/pipermail/gcc-patches/2022-September/602130.html Best Thomas
Thanks, I haven't observed it. Waiting for it, Claudiu On Mon, Sep 26, 2022 at 2:49 PM Thomas Neumann <neumann@in.tum.de> wrote: > > Hi Claudiu, > > > This change prohibits compiling of ARC backend: > > > >> + gcc_assert (in_shutdown || ob); > > > > in_shutdown is only defined when ATOMIC_FDE_FAST_PATH is defined, > > while gcc_assert is outside of any ifdef. Please can you revisit this > > line and change it accordingly. > > I have a patch ready, I am waiting for someone to approve my patch: > > https://gcc.gnu.org/pipermail/gcc-patches/2022-September/602130.html > > Best > > Thomas
> On 26 Sep 2022, at 12:49, Thomas Neumann via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > Hi Claudiu, > >> This change prohibits compiling of ARC backend: >>> + gcc_assert (in_shutdown || ob); >> in_shutdown is only defined when ATOMIC_FDE_FAST_PATH is defined, >> while gcc_assert is outside of any ifdef. Please can you revisit this >> line and change it accordingly. > > I have a patch ready, I am waiting for someone to approve my patch: > > https://gcc.gnu.org/pipermail/gcc-patches/2022-September/602130.html You might also want to include Rainer’s patch, AFAIR patches to fix bootstrap are allowed to proceed as an exception to the usual rules, Iain
Hi Iain, > You might also want to include Rainer’s patch, > > AFAIR patches to fix bootstrap are allowed to proceed as an exception to > the usual rules, I was not aware of that. I have pushed the patch below now (including Rainer's change), I will update the code if requested. Best Thomas fix assert in __deregister_frame_info_bases When using the atomic fast path deregistering can fail during program shutdown if the lookup structures are already destroyed. The assert in __deregister_frame_info_bases takes that into account. In the non-fast-path case however is not aware of program shutdown, which caused a compiler error on such platforms. We fix that by introducing a constant for in_shutdown in non-fast-path builds. We also drop the destructor priority, as it is not supported on all platforms and we no longer rely upon the priority anyway. libgcc/ChangeLog: * unwind-dw2-fde.c: Introduce a constant for in_shutdown for the non-fast-path case. Drop destructor priority. diff --git a/libgcc/unwind-dw2-fde.c b/libgcc/unwind-dw2-fde.c index d237179f4ea..3c0cc654ec0 100644 --- a/libgcc/unwind-dw2-fde.c +++ b/libgcc/unwind-dw2-fde.c @@ -51,7 +51,7 @@ static struct btree registered_frames; static bool in_shutdown; static void -release_registered_frames (void) __attribute__ ((destructor (110))); +release_registered_frames (void) __attribute__ ((destructor)); static void release_registered_frames (void) { @@ -67,6 +67,8 @@ static void init_object (struct object *ob); #else +/* Without fast path frame deregistration must always succeed. */ +static const int in_shutdown = 0; /* The unseen_objects list contains objects that have been registered but not yet categorized in any way. The seen_objects list has had
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; }