Bug 220151 - [libc] syslog() thread unsafety: mutex lock leak
Summary: [libc] syslog() thread unsafety: mutex lock leak
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 11.0-STABLE
Hardware: Any Any
: --- Affects Some People
Assignee: Konstantin Belousov
URL:
Keywords:
Depends on:
Blocks: 186114
  Show dependency treegraph
 
Reported: 2017-06-20 09:46 UTC by Eugene Grosbein
Modified: 2017-07-21 13:16 UTC (History)
3 users (show)

See Also:
eugen: mfc-stable11?
eugen: mfc-stable10?


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eugene Grosbein freebsd_committer freebsd_triage 2017-06-20 09:46:27 UTC
Hi!

Our [v]syslog() implementation in src/lib/libc/gen/syslog.c
tries to be thread-safe and uses "syslog_mutex".

It may lock this mutex then call blocking system calls like sendto().
If a thread owning this mutex is pthread_cancel()'d in process,
the mutex stays UMUTEX_CONTESTED and every other thread calling [v]syslog() deadlocks.

I can reproduce this with net/mpd5 daemon reliably within some seconds
from the beginning of my stress test involving RADIUS so mpd5 runs multi-threaded.

This problem seems to be root cause of multiple complaints
about mpd5 being unstable under FreeBSD 9.x+ version (PR: 186114, 214482).

There is a patch by Konstantin Belousov solving this problem attached to the PR 186114: https://bugs.freebsd.org/bugzilla/attachment.cgi?id=183537
Comment 1 Eric van Gyzen freebsd_committer freebsd_triage 2017-06-27 18:10:31 UTC
If I understand correctly, this is already fixed in 12, 11, and 10 by r320052, r320311, and r320312, respectively.