Deadlock in init

walter harms wharms at bfs.de
Fri Nov 21 13:22:36 UTC 2014


1. i am not the expert on signal issues

ntl
man 7 signal
  Async-signal-safe functions

       POSIX has the concept of "safe function".   If  a  signal
       interrupts  the  execution  of an unsafe function, and handler calls an
       unsafe function, then the behavior of the program is undefined.

          ....
         socket()
           socketpair()
           stat()
           symlink()
           sysconf()
           tcdrain()
          ....

no syslog().

Does the problem vanish when you use e.g. write() ?

re,
 wh


Am 21.11.2014 00:37, schrieb Seth Bollinger:
> Hello All,
> 
> We recently ran into a deadlock in init.  The window is small, but I
> figured I would post to the list anyway.
> 
> There are syslog messages in the signal handler for reboot and shutdown.
> Internally this function grabs a lock.  If the main loop is trying to grab
> this lock at exactly the same time (also posting a syslog message), then a
> deadlock is possible.
> 
> Here's a small example program that should demonstrate the issue.
> 
> #include <stdio.h>
> #include <stdlib.h>
> #include <syslog.h>
> #include <signal.h>
> 
> void handler(int sig)
> {
>         syslog(LOG_INFO, "handler");
> }
> 
> void main(int argc, char **argv)
> {
>         signal(SIGUSR1, handler);
> 
>         while (1)
>         {
>                 syslog(LOG_INFO, "main");
>         }
> }
> 
> while [ true ]; do kill -USR1 PID; done
> 
> Thanks,
> 
> Seth
> 
> 
> 
> 
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox


More information about the busybox mailing list