From owner-freebsd-hackers@FreeBSD.ORG Fri Jul 20 19:14:07 2007 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C664916A41F for ; Fri, 20 Jul 2007 19:14:07 +0000 (UTC) (envelope-from romain@blogreen.org) Received: from postfix1-g20.free.fr (postfix1-g20.free.fr [212.27.60.42]) by mx1.freebsd.org (Postfix) with ESMTP id 5B29C13C45D for ; Fri, 20 Jul 2007 19:14:07 +0000 (UTC) (envelope-from romain@blogreen.org) Received: from smtp3-g19.free.fr (smtp3-g19.free.fr [212.27.42.29]) by postfix1-g20.free.fr (Postfix) with ESMTP id 9043E1724F25 for ; Fri, 20 Jul 2007 20:50:11 +0200 (CEST) Received: from marvin.blogreen.org (marvin.blogreen.org [82.247.213.140]) by smtp3-g19.free.fr (Postfix) with ESMTP id 071448196 for ; Fri, 20 Jul 2007 20:50:09 +0200 (CEST) Received: by marvin.blogreen.org (Postfix, from userid 1001) id 8F1435C04E; Fri, 20 Jul 2007 20:50:09 +0200 (CEST) Date: Fri, 20 Jul 2007 20:50:09 +0200 From: Romain =?iso-8859-1?Q?Tarti=E8re?= To: freebsd-hackers Message-ID: <20070720185009.GA79090@marvin.blogreen.org> Mail-Followup-To: freebsd-hackers Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Dxnq1zWXvFF0Q93v" Content-Disposition: inline User-Agent: Mutt/1.4.2.3i Subject: Insufficient locking in log() / kvprintf() / somewhere? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Jul 2007 19:14:07 -0000 --Dxnq1zWXvFF0Q93v Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello FreeBSD hackers! I recently got some apache problems (maybe just forgetting to restart it after an update, but it is not the interest of this e-mail) and each httpd process was segfaulting as soon as created. I got surprising things like that in my systems log: =3D=3D=3D begin snippet =3D=3D=3D > pid 85055 (httpd), uid 80: exited on signal 11 > pid 85063 (httpd), uid 80: exited on signal 11 > pid 85064 (httpd), uid 80: exited on signal 11 > pid 85066 (httpd), uid 80: exited on signal 11 > pid 85065 (httpd), uid 80: exited on signal 11 > <<66>>ppiidd 8580506678 ((hhtttptdp)d,), uuid id8 0: 8ex0: eixteidt eo= d no ns isginganla l 111 > 1 >=20 > pid 85070 (httpd), uid 80: exited on signal 11 > pid 85069 (httpd), uid 80: exited on signal 11 =3D=3D=3D end snippet =3D=3D=3D (uname: FreeBSD 6.2-STABLE #4: Thu Jun 7 00:56:26 CEST 2007 i386) Obviously, having two processes on a dual core machine crashing simultaneously produce weird stuff. I poked a bit around in /usr/src/sys/kern: > % grep -n 'exited on signal' * > kern_sig.c:2452: "pid %d (%s), uid %d: exited on signal %d%s\n", The code in void sigexit(td, sig) is as follow: > if (kern_logsigexit) > log(LOG_INFO, > "pid %d (%s), uid %d: exited on signal %d%s\n", > p->p_pid, p->p_comm, > td->td_ucred ? td->td_ucred->cr_uid : -1, > sig &~ WCOREFLAG, > sig & WCOREFLAG ? " (core dumped)" : ""); The log() function is declared in /usr/src/sys/kern/subr_prf.c:229 as this: > void > log(int level, const char *fmt, ...) > { > va_list ap; > struct putchar_arg pca; > > pca.tty =3D NULL; > pca.pri =3D level; > pca.flags =3D log_open ? TOLOG : TOCONS; > > va_start(ap, fmt); > kvprintf(fmt, putchar, &pca, 10, ap); > va_end(ap); > > msgbuftrigger =3D 1; > } =2E.. so basically is calls kvprintf witch actually writes the message AFAIK. The issue is maybe a weird case-corner, but maybe some kind of locking may have sense to avoid this? Kind regards, Romain --=20 Romain Tarti=E8re http://romain.blogreen.org/ pgp: 8DAB A124 0DA4 7024 F82A E748 D8E9 A33F FF56 FF43 (ID: 0xFF56FF43) (plain text =3Dnon-HTML=3D PGP/GPG encrypted/signed e-mail much appreciated) --Dxnq1zWXvFF0Q93v Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4 (FreeBSD) iD8DBQFGoQPh2OmjP/9W/0MRAuOwAJwNFiMgvmI2qoIETzvlfyU7wehlwgCfQxXh MJvLYctf4kltW1gVlZYNKQ8= =WPjV -----END PGP SIGNATURE----- --Dxnq1zWXvFF0Q93v--