From patchwork Thu Oct 31 19:20:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Adhemerval Zanella (Code Review)" X-Patchwork-Id: 1187642 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-106510-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gnutoolchain-gerrit.osci.io Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="A0tt8oYi"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 473wCk701Cz9sNw for ; Fri, 1 Nov 2019 06:21:06 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:message-id:subject:references :reply-to:mime-version:content-transfer-encoding:content-type; q=dns; s=default; b=ms65AwYcpCNnyDtguWqPKeeKx06YGA7w6JopILsk8tN D2dxik9jPSuFv3gPkG/HT7L1NGsDMue/KoBYBqHuRA2FeB5683spbijdcAIg49t4 t/1H7GBgqRXpdTjXsf+gPZRhrKM/hl0cHGn7b/edXYHcnRKC9+y1sXWFt38wx8Lw = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:message-id:subject:references :reply-to:mime-version:content-transfer-encoding:content-type; s=default; bh=oO2R6xc4bNYIAuXS7Ms7RWLapDk=; b=A0tt8oYiyf+0luuiu ZoFM0DzgSa2SwCy20fu6eEMKD4HptQmW7YLNA6T2qtZMwpZcEk8Sn6SZoRnoYpey 9fh4+y1x5fQSG0JoKzQwDnH5nf/Oq1ZZJPz6cVnkxGYTO4VGpELDerVKfxvRI//x MTlAerxiA2JmLAMkRDzC+90UHU= Received: (qmail 119618 invoked by alias); 31 Oct 2019 19:20:47 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 119548 invoked by uid 89); 31 Oct 2019 19:20:47 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=HX-Languages-Length:2429, 1736 X-HELO: mx1.osci.io X-Gerrit-PatchSet: 1 Date: Thu, 31 Oct 2019 15:20:40 -0400 From: "Florian Weimer (Code Review)" To: libc-alpha@sourceware.org Cc: Florian Weimer Message-ID: Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange Subject: [review] Enhance _dl_catch_exception to allow disabling exception handling X-Gerrit-Change-Id: Iec1bf642ff95a349fdde8040e9baf851ac7b8904 X-Gerrit-Change-Number: 466 X-Gerrit-ChangeURL: X-Gerrit-Commit: 637eb1c598b2a9d9ace79ab0f21bcc4802e565d2 References: Reply-To: fweimer@redhat.com, fweimer@redhat.com, libc-alpha@sourceware.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3-75-g9005159e5d Change URL: https://gnutoolchain-gerrit.osci.io/r/c/glibc/+/466 ...................................................................... Enhance _dl_catch_exception to allow disabling exception handling In some cases, it is necessary to introduce noexcept regions where raised dynamic loader exceptions (e.g., from lazy binding) are fatal, despite being nested in a code region with an active exception handler. This change enhances _dl_catch_exception with to provide such a capability. The existing function is reused, so that it is not necessary to introduce yet another function with a similar purpose. Change-Id: Iec1bf642ff95a349fdde8040e9baf851ac7b8904 Reviewed-by: Carlos O'Donell --- M elf/dl-error-skeleton.c M sysdeps/generic/ldsodefs.h 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/elf/dl-error-skeleton.c b/elf/dl-error-skeleton.c index a261af6..7caf28f 100644 --- a/elf/dl-error-skeleton.c +++ b/elf/dl-error-skeleton.c @@ -173,6 +173,18 @@ _dl_catch_exception (struct dl_exception *exception, void (*operate) (void *), void *args) { + /* If exception is NULL, temporarily disable exception handling. + Exceptions during operate (args) are fatal. */ + if (exception == NULL) + { + struct catch *const old = catch_hook; + catch_hook = NULL; + operate (args); + /* If we get here, the operation was successful. */ + catch_hook = old; + return 0; + } + /* We need not handle `receiver' since setting a `catch' is handled before it. */ diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h index 85b7936..ed0aed7 100644 --- a/sysdeps/generic/ldsodefs.h +++ b/sysdeps/generic/ldsodefs.h @@ -867,7 +867,9 @@ /* Call OPERATE (ARGS). If no error occurs, set *EXCEPTION to zero. Otherwise, store a copy of the raised exception in *EXCEPTION, - which has to be freed by _dl_exception_free. */ + which has to be freed by _dl_exception_free. As a special case, if + EXCEPTION is null, call OPERATE (ARGS) with exception handling + disabled (so that exceptions are fatal). */ int _dl_catch_exception (struct dl_exception *exception, void (*operate) (void *), void *args); libc_hidden_proto (_dl_catch_exception)