Date: Sun, 15 Aug 2004 13:02:20 -0400 (EDT) From: Robert Watson <rwatson@FreeBSD.org> To: threads@FreeBSD.org Subject: thread-unsafe syslog code in libc? Message-ID: <Pine.NEB.3.96L.1040815125617.30898L-100000@fledge.watson.org>
next in thread | raw e-mail | index | archive | help
I recently resolved a kernel race reported by Martin Blapp in which a file descriptor had connect() called on it by one thread, and was simultaenously close()'d by another. The bug resulted in a kernel crash, which is certainly not the right response, and I'm working on a number of aspects of that problem. However, this also speaks to a race in user space. The socket in question was being connected to /var/run/log, so I believe it was made from the libc syslog code. A glance at src/lib/libc/gen/syslog.c suggests that things are indeed a bit un-threadsafe, especially in vsyslog(), where things get connected and disconnected a fair amount. I'm guessing we need some sort of synchronization around use of that file descriptor to prevent this sort of race from happening in the future, as potentially it might lose log records, etc. It's also doing a lot of work by reconnecting so frequently, and I have to wonder if we can't improve the performance of applications using syslog by doing a better job at using a single connection... Robert N M Watson FreeBSD Core Team, TrustedBSD Projects robert@fledge.watson.org Principal Research Scientist, McAfee Research
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.NEB.3.96L.1040815125617.30898L-100000>