[PATCH] Mark syslog as MT-unsafe (bug 26100)

Zack Weinberg zackw@panix.com
Mon Jun 15 18:51:28 GMT 2020


On Mon, Jun 15, 2020 at 2:07 PM Carlos O'Donell <carlos@redhat.com> wrote:
> On 6/15/20 10:18 AM, Zack Weinberg wrote:
> > Messages to syslog need to be serialized over the whole process
> > _anyway_, so I don't see a problem with having
> > syslog/openlog/closelog/setlogmask take an internal mutex around the
> > shared global state.
>
> When we add new locks we also have to consider MT-fork issues and if
> any existing semi-legitimate uses may be impacted by the locks taken
> by these functions.

Hmm.  I can think of two scenarios where that could be a problem.
First, if one thread is calling syslog at the same time as another
thread calls fork, so the syslog lock is locked in the child process,
and then the child tries to call syslog, it will deadlock.  This seems
like something that could easily happen and people would want it to
work, but we could deal with it with another internal fork handler.

Second, if fork is called from an async signal handler that
interrupted the guts of syslog, syslog will again be unusable in the
child; but in that case the child is required to use only AS-safe
functions, so maybe we can get away with it?

Can you think of any others?

zw


More information about the Libc-alpha mailing list