[PATCH] Mark syslog as MT-unsafe (bug 26100)
Mon Jun 15 18:07:13 GMT 2020
On 6/15/20 10:18 AM, Zack Weinberg wrote:
> On Mon, Jun 15, 2020 at 8:31 AM Andreas Schwab <email@example.com> wrote:
>> On Jun 15 2020, Florian Weimer wrote:
>>> If it's not too hard, I think it would be a reasonable enhancement.
>>> Lack of thread safety is surprising here, and I expect that a lot of
>>> code assumes it.
>> Its use of shared global state makes it inherently non-safe.
> 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. However, for further bulletproofing we would
> need to promise that these functions never acquire any _other_ locks,
> in particular that they do not call malloc, and I don't know whether
> they do now.
> If we're going to do this it should be clearly documented as a GNU
> extension; POSIX does not guarantee this.
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.
More information about the Libc-alpha