]> Savannah Git Hosting - gnulib.git/commitdiff
fatal-signal: Make multithread-safe.
authorBruno Haible <bruno@clisp.org>
Sat, 27 Jun 2020 22:40:04 +0000 (00:40 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 27 Jun 2020 22:40:04 +0000 (00:40 +0200)
* lib/fatal-signal.c (at_fatal_signal): Don't free the old actions array.

ChangeLog
lib/fatal-signal.c

index 7e046bc402ee5d390ab570c207a4a688e1f9dfcf..12dadaaa368c9ec27f1f9617637ca3469efb0eb2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2020-06-27  Bruno Haible  <bruno@clisp.org>
+
+       fatal-signal: Make multithread-safe.
+       * lib/fatal-signal.c (at_fatal_signal): Don't free the old actions array.
+
 2020-06-27  Bruno Haible  <bruno@clisp.org>
 
        clean-temp: Don't force deletion of temporary files on native Windows.
index 975393b4a0ebde18eeac36bf21f75cab82b46d90..c6f8dacbdeba58296c6a58615cba946ef39339d1 100644 (file)
@@ -239,8 +239,15 @@ at_fatal_signal (action_t action)
       actions = new_actions;
       actions_allocated = new_actions_allocated;
       /* Now we can free the old actions array.  */
+      /* No, we can't do that.  If fatal_signal_handler is running in a
+         different thread and has already fetched the actions pointer (getting
+         old_actions) but not yet accessed its n-th element, that thread may
+         crash when accessing an element of the already freed old_actions
+         array.  */
+      #if 0
       if (old_actions != static_actions)
         free (old_actions);
+      #endif
     }
   /* The two uses of 'volatile' in the types above (and ISO C 99 section
      5.1.2.3.(5)) ensure that we increment the actions_count only after