From patchwork Sat Nov 16 15:30:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Simon Marchi (Code Review)" X-Patchwork-Id: 35982 Received: (qmail 92146 invoked by alias); 16 Nov 2019 15:30:36 -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 92072 invoked by uid 89); 16 Nov 2019 15:30:27 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.5 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=8619 X-HELO: mx1.osci.io X-Gerrit-PatchSet: 4 Date: Sat, 16 Nov 2019 10:30:10 -0500 From: "Sourceware to Gerrit sync (Code Review)" To: Florian Weimer , libc-alpha@sourceware.org Cc: Carlos O'Donell Auto-Submitted: auto-generated X-Gerrit-MessageType: merged Subject: [pushed] 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: 2a764c6ee848dfe92cb2921ed3b14085f15d9e79 In-Reply-To: References: Reply-To: noreply@gnutoolchain-gerrit.osci.io, fweimer@redhat.com, libc-alpha@sourceware.org, carlos@redhat.com MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3-79-g83ff7f88f1 Message-Id: <20191116153010.4D5D120AF6@gnutoolchain-gerrit.osci.io> Sourceware to Gerrit sync has submitted this change. 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 --- M elf/dl-error-skeleton.c M sysdeps/generic/ldsodefs.h 2 files changed, 15 insertions(+), 1 deletion(-) Approvals: Carlos O'Donell: Looks good to me, approved 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 4d67c05..891049d 100644 --- a/sysdeps/generic/ldsodefs.h +++ b/sysdeps/generic/ldsodefs.h @@ -861,7 +861,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)