]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Enhance _dl_catch_exception to allow disabling exception handling
authorFlorian Weimer <fweimer@redhat.com>
Thu, 31 Oct 2019 12:23:06 +0000 (13:23 +0100)
committerFlorian Weimer <fweimer@redhat.com>
Sat, 16 Nov 2019 14:57:01 +0000 (15:57 +0100)
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

elf/dl-error-skeleton.c
sysdeps/generic/ldsodefs.h

index a261af68b6670bb0ef49774f55de9ebec6e6bc49..7caf28f0fdd0bd2786ec976cfb57a51ac2bcc242 100644 (file)
@@ -173,6 +173,18 @@ int
 _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.  */
 
index 4d67c05e72ad167ea4ed7a5a873e2b21c87279a1..891049dd1a3acc4e65db3bdd6c4680bd90b24c0f 100644 (file)
@@ -861,7 +861,9 @@ libc_hidden_proto (_dl_catch_error)
 
 /* 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)