Message ID | c72ceaca-53e4-3deb-c0a6-57af9b2935a4@codesourcery.com |
---|---|
State | Accepted |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp286644wrs; Fri, 14 Oct 2022 10:05:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM62OgD35+8tzuMSJx98xWQyWhVzg0oalhmdsPG+yo2IZ4eMOFlAJKu5t2HKrgQONjz4vcQe X-Received: by 2002:a05:6402:548f:b0:457:ed40:5f58 with SMTP id fg15-20020a056402548f00b00457ed405f58mr5024859edb.408.1665767101718; Fri, 14 Oct 2022 10:05:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665767101; cv=none; d=google.com; s=arc-20160816; b=BzR4pu2TwcQCYBI6iVUmKbtF9NDIDHTfh1fKv5wlpbCqarM3y5Vdsia0FgSeMvNyUq RVpdwEYpWkUWPS+ZnkdHHZBZBQe4gr0c5aj9uUdgK+z37Ae/ckXsyB5qUNN9EU/SGayk n8XrsdwZdV95vwe7PwAQ1SIkhLoaEs8j33A5zPEIbp8F5Yohrnlozjqf4ST8hC/eHeLL BdnyUgXypdYrGHwYiOZJCRu/MQ1FZ2HNPcb3eJ5QTXMwRHlCMaWJ3vFYeOPxFKV2Yxqx lpGtcK6cf1QWdLMBKKTHJZSEkYvn3iJQS6NG7QDEVk1RkP7hM4duN48YXSmw6tg7/wIb Uzyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:from:to :content-language:user-agent:mime-version:date:message-id :ironport-sdr:dmarc-filter:delivered-to; bh=9bj680VCtPvGyKn9Egh34+wKq9Y6Gu7hJndck70dd+M=; b=vTo9EQZNnCUDO3nXOkjWVaaguybJUQd8lTswxLtFGe9idInvGCpq1lFzVYD464Viuz NkP/U4Te7H8b2DXZLHOdRMYBEIoGFVaLznbHcJyVcoKFg0vlMrt7EmXicu7UA8961TKH /BbDCAjiAHQ4Z6pameiU95ddidVKKLmWGDisDP8EFfbNa2vEHokp5edBpeZ5WH+PGNUj 9CPweKOBkOYevYPsQopbn/qh5W59TjUulKBX4IBg043XW3xhKYYkBPL1MgZ39HVqZQ9W zhRilcGIv05DuaFcUBo2Ea+D5Km1QH6GWu07HOFHumFPPVQ9AgI9PBHIdAJaJX5yD6H8 KLrg== ARC-Authentication-Results: i=1; mx.google.com; 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" Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id y10-20020a50eb0a000000b00458ab54baa5si2475931edp.503.2022.10.14.10.05.01 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 10:05:01 -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; 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" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C81EC3857B93 for <ouuuleilei@gmail.com>; Fri, 14 Oct 2022 17:04:41 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa1.mentor.iphmx.com (esa1.mentor.iphmx.com [68.232.129.153]) by sourceware.org (Postfix) with ESMTPS id 758C83858D38 for <gcc-patches@gcc.gnu.org>; Fri, 14 Oct 2022 17:04:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 758C83858D38 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.95,184,1661846400"; d="scan'208";a="87540523" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa1.mentor.iphmx.com with ESMTP; 14 Oct 2022 09:04:14 -0800 IronPort-SDR: rZz40vDIwD2DSXYm7pPq2XcK/AXneLqSHgC31UQ2f4jfqpiVIwJvimi1vI0Dh5jAdsBkMMT5a4 Q86ZMHNQBAan9kxnPzcJrp43WL/qes7AaiPiCXBZc43rgHgEjjpHvC2EWkb9QNdahFKJ4qCCa6 0l3tZLLLeKbg11uI2KNaP32MJSR+WYDMC6rFlKw1aFG79wRv2rxPgl0pkLWX2b1F9e7MoMDPA4 +D9/xXzi4/azIdHNUgw1AoHvPRRKO7JSuj/uJ76tiJraxRqx5jU6Yk7XAv2Yccq6WqEPQ4Z2XO ZE0= Content-Type: multipart/mixed; boundary="------------45VvYFMWFSpp6pmKvm8UIUWc" Message-ID: <c72ceaca-53e4-3deb-c0a6-57af9b2935a4@codesourcery.com> Date: Fri, 14 Oct 2022 18:04:06 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.3.2 Content-Language: en-GB To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>, Jakub Jelinek <jakub@redhat.com> From: Andrew Stubbs <ams@codesourcery.com> Subject: [PATCH] libgomp: fix hang on fatal error X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-15.mgc.mentorg.com (139.181.222.15) To svr-ies-mbx-12.mgc.mentorg.com (139.181.222.12) X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, 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> 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?1746683404349618026?= X-GMAIL-MSGID: =?utf-8?q?1746683404349618026?= |
Series |
libgomp: fix hang on fatal error
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | success | Github commit url |
Commit Message
Andrew Stubbs
Oct. 14, 2022, 5:04 p.m. UTC
This patch fixes a problem in which fatal errors inside mutex-locked regions (i.e. basically anything in the plugin) will cause it to hang up trying to take the lock to clean everything up. Using abort() instead of exit(1) bypasses the atexit handlers and solves the problem. OK for mainline? Andrew libgomp: fix hang on fatal error Don't try to clean up if a fatal error occurs in libgomp. Typically the cleanup is not reentrant so we end up hung on a lock. libgomp/ChangeLog: * error.c (gomp_vfatal): Use abort instead of exit.
Comments
On Fri, Oct 14, 2022 at 06:04:06PM +0100, Andrew Stubbs wrote: > This patch fixes a problem in which fatal errors inside mutex-locked regions > (i.e. basically anything in the plugin) will cause it to hang up trying to > take the lock to clean everything up. > > Using abort() instead of exit(1) bypasses the atexit handlers and solves the > problem. > > OK for mainline? > > Andrew > libgomp: fix hang on fatal error > > Don't try to clean up if a fatal error occurs in libgomp. Typically the > cleanup is not reentrant so we end up hung on a lock. > > libgomp/ChangeLog: > > * error.c (gomp_vfatal): Use abort instead of exit. > > diff --git a/libgomp/error.c b/libgomp/error.c > index 50ed85eedb1..25548c14a82 100644 > --- a/libgomp/error.c > +++ b/libgomp/error.c > @@ -77,7 +77,7 @@ void > gomp_vfatal (const char *fmt, va_list list) > { > gomp_verror (fmt, list); > - exit (EXIT_FAILURE); > + abort (); > } > > void I don't like this, abort has quite different user visible behavior from exit, e.g. the former often dumps core. I believe in most places libgomp handles this by releasing locks before calling gomp_{,v}fatal: gomp_mutex_unlock (®ister_lock); gomp_fatal ("Out of memory allocating %lu bytes", (unsigned long) size); gomp_mutex_unlock (&devicep->lock); gomp_fatal ("Copying of %s object [%p..%p) to %s object [%p..%p) failed", src, srcaddr, srcaddr + size, dst, dstaddr, dstaddr + size); etc. I could live with a gomp_fatal/gomp_vfatal alternative that would use _exit/_Exit (but not sure if it is supported on all targets where libgomp is) for uses where releasing locks is for whatever reason not an option. Jakub
On Wed, Oct 19, 2022 at 03:27:52PM +0200, Jakub Jelinek via Gcc-patches wrote: > > --- a/libgomp/error.c > > +++ b/libgomp/error.c > > @@ -77,7 +77,7 @@ void > > gomp_vfatal (const char *fmt, va_list list) > > { > > gomp_verror (fmt, list); > > - exit (EXIT_FAILURE); > > + abort (); > > } > > > > void > > I don't like this, abort has quite different user visible behavior > from exit, e.g. the former often dumps core. > > I believe in most places libgomp handles this by releasing locks before > calling gomp_{,v}fatal: > gomp_mutex_unlock (®ister_lock); > gomp_fatal ("Out of memory allocating %lu bytes", (unsigned long) size); > > gomp_mutex_unlock (&devicep->lock); > gomp_fatal ("Copying of %s object [%p..%p) to %s object [%p..%p) failed", > src, srcaddr, srcaddr + size, dst, dstaddr, dstaddr + size); > > etc. > I could live with a gomp_fatal/gomp_vfatal alternative that would > use _exit/_Exit (but not sure if it is supported on all targets where > libgomp is) for uses where releasing locks is for whatever reason > not an option. Or yet another possibility would be not use gomp_fatal from within the plugins, but use gomp_error instead and through possibly adjusted plugin APIs tell libgomp that there was a fatal error and let libgomp unlock anything that needs unlocking and exit (EXIT_FAILURE); afterwards. Jakub
diff --git a/libgomp/error.c b/libgomp/error.c index 50ed85eedb1..25548c14a82 100644 --- a/libgomp/error.c +++ b/libgomp/error.c @@ -77,7 +77,7 @@ void gomp_vfatal (const char *fmt, va_list list) { gomp_verror (fmt, list); - exit (EXIT_FAILURE); + abort (); } void