Bug: deadlock from msyslog
kurt at roeckx.be
Wed Jan 20 11:43:44 UTC 2016
On Wed, Jan 20, 2016 at 02:31:29AM -0800, Hal Murray wrote:
> A while (months) ago, we had troubles with msyslog scrambling output when
> called from the DNS thread and the main thread at the same time. That was
> fixed by adding a lock.
> That will deadlock if a signal handler calls msyslog when the signal goes off
> in the middle of a msyslog call.
> I poked around a bit. There are a few signal handlers that call msyslog. I
> think they can be deferred. It's probably worthwhile to study all the signal
> usage and make some notes.
You should be careful with signal handers. The only thing you can
really do do in standard C is access a volatile sig_atomic_t, or
call functions like abort(), _exit(), or signal(). Your OS might provide
more async safe function, but that's implementation defined.
POSIX has a relative long list of such functions.
OpenBSD also defines some others async safe functions, like snprint(),
vsprint() and syslog_r().
More information about the devel