Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Jun 2017 20:49:36 +0700
From:      Eugene Grosbein <eugen@grosbein.net>
To:        FreeBSD Stable <freebsd-stable@FreeBSD.org>
Cc:        Gleb Smirnoff <glebius@FreeBSD.org>, Konstantin Belousov <kib@freebsd.org>
Subject:   syslog() thread unsafety
Message-ID:  <59413EF0.20608@grosbein.net>

next in thread | raw e-mail | index | archive | help
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.

I've tried to wrap every mpd5's [v]syslog() call around with
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate) and
pthread_setcancelstate(oldstate, NULL) statements and this eliminates the problem
but that's not a solution in any way.

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

Please take a look.

Eugene Grosbein



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?59413EF0.20608>