Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-16084

Calling exit() from a signal handler is unsafe

    XMLWordPrintable

    Details

      Description

      Marko Mäkelä noticed a deadlock in safe_process, in exit() from a signal hander.

      Quoth the StackOverflow https://stackoverflow.com/a/8833602/547065 talking about async-signal-safe-functions in POSIX: "...you can see functions _Exit(), _exit() and abort(), but notably not exit(). So you shalt not call it from a signal handler."

      See also http://pubs.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_04.html

      Thread 1 (Thread 0x7f1e8904e740 (LWP 6393)):
      #0  __lll_lock_wait_private ()
          at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95
      #1  0x00007f1e87f8371b in __run_exit_handlers (status=5, 
          listp=0x7f1e88300718 <__exit_funcs>, 
          run_list_atexit=run_list_atexit@entry=true, run_dtors=run_dtors@entry=true)
          at exit.c:56
      #2  0x00007f1e87f8392a in __GI_exit (status=<optimized out>) at exit.c:139
      #3  0x0000558b27bce288 in kill_child (was_killed=false)
          at /mariadb/10.3/mysql-test/lib/My/SafeProcess/safe_process.cc:119
      #4  0x0000558b27bce32e in handle_signal (sig=15)
          at /mariadb/10.3/mysql-test/lib/My/SafeProcess/safe_process.cc:139
      #5  <signal handler called>
      #6  __run_exit_handlers (status=0, listp=0x7f1e88300718 <__exit_funcs>, 
          run_list_atexit=run_list_atexit@entry=true, run_dtors=run_dtors@entry=true)
          at exit.c:120
      #7  0x00007f1e87f8392a in __GI_exit (status=<optimized out>) at exit.c:139
      #8  0x0000558b27bce249 in kill_child (was_killed=true)
          at /mariadb/10.3/mysql-test/lib/My/SafeProcess/safe_process.cc:111
      #9  0x0000558b27bce32e in handle_signal (sig=17)
          at /mariadb/10.3/mysql-test/lib/My/SafeProcess/safe_process.cc:139
      #10 <signal handler called>
      #11 0x00007f1e88010404 in __GI___nanosleep (
          requested_time=requested_time@entry=0x7ffe7a09e860, 
          remaining=remaining@entry=0x7ffe7a09e860)
          at ../sysdeps/unix/sysv/linux/nanosleep.c:28
      #12 0x00007f1e8801030a in __sleep (seconds=0) at ../sysdeps/posix/sleep.c:55
      #13 0x0000558b27bce9cf in main (argc=10, argv=0x7ffe7a09eb08)
          at /mariadb/10.3/mysql-test/lib/My/SafeProcess/safe_process.cc:301
      

        Attachments

          Activity

            People

            Assignee:
            wlad Vladislav Vaintroub
            Reporter:
            wlad Vladislav Vaintroub
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: