From owner-freebsd-threads@FreeBSD.ORG Fri Nov 21 19:56:21 2014 Return-Path: Delivered-To: freebsd-threads@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id BAB6E6DB; Fri, 21 Nov 2014 19:56:21 +0000 (UTC) Received: from 0.mx.codelabs.ru (0.mx.codelabs.ru [144.206.233.71]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5A6C31AD; Fri, 21 Nov 2014 19:56:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=codelabs.ru; s=three; h=Sender:In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=8LnyTYpL/8fg4RYqxwFKgZcmgC4dzt6srtq/243EkDc=; b=JzB4UJ257C7bNtoRDuvj2wa2MgnTn/gzRDUh34J4TbH7YkYrVNvHTCKHSsxdsJt4NiM/GSzDbrY4Y1nl4DCCwV3mxIsO+sE9Ar1gdsX3ngHkS+MxyMCVpBTgQPk3WxTCBVkgvkkgRuFO4VgOPBAn4ujPtEAg1gexOYApT2PY6IC2/n11UEazxEmxQmDdrzKUX6PqM5c+wm9QPw48eDEYIc+h2iuspXpz/mGT8Kn/S3CHbR2i+ytvVnSq/uIrnREtKOWE/ENb//C7K+D6OghxFduPDQ1Esescmxno/QD+HawIf+njODyhJOPHP0G5VSc2Pm1y8Qf5Qh5reUoQkw4/j9pK6AEzgIZRXpOoO1fSs+koAoK5cEgmH7rEEDFTN9zR/OcePI7mSRWU5O23A1sfFYkq7H35WgyLUUxtiHtOI/FXCk6Xp6i5hBbhRJl8BOHkcMMkHCzjYYpU9jf/BMXSrlBqsFh1tQQ3+X7/+xghM1GO9pz/Kls49JtINpszeK59NekqltW2ld9qTqowDeomlx0z87yYhSkLirc9rJ2eL3n0Z++4KjUaQfsblDyhvM3XzMpKxtU63gQHRBH4ILImb0AgrxfKtk8nGeFD87uKwLycmOLYSDQx8HbU6e5A3kbCiEpRYtf7JIAFMrkml/ZRlsvgusEchdRnX9hyYBIIz5U=; Received: from light.codelabs.ru (v-light.codelabs.ru [144.206.233.83]) by 0.mx.codelabs.ru with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) id 1XruJW-000Nkm-SW; Fri, 21 Nov 2014 23:56:19 +0400 Date: Fri, 21 Nov 2014 22:55:55 +0300 From: Eygene Ryabinkin To: Konstantin Belousov Subject: Re: [CFR][PATCH] Call proper signal handler from libthr for non-SA_SIGINFO case Message-ID: References: <20141120194925.GK17068@kib.kiev.ua> <20141121165658.GP17068@kib.kiev.ua> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="tsOsTdHNUZQcU9Ye" Content-Disposition: inline In-Reply-To: <20141121165658.GP17068@kib.kiev.ua> Sender: rea@codelabs.ru Cc: davidxu@FreeBSD.org, freebsd-threads@FreeBSD.org X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Nov 2014 19:56:21 -0000 --tsOsTdHNUZQcU9Ye Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Fri, Nov 21, 2014 at 06:56:58PM +0200, Konstantin Belousov wrote: > On Fri, Nov 21, 2014 at 07:07:14PM +0300, Eygene Ryabinkin wrote: > > So, it looks like a kernel bug (since if we request SA_SIGINFO, we > > should get the proper handler to be called even for the SA_RESETHAND > > case). I see two possibilities: > >=20 > > - invoke SA_RESETHAND processing inside mach-dependent code; that's > > a kind of ugly and makes mach-specific code to deal with the > > generic signal handling logics; > >=20 > > - pass information about SA_SIGINFO "out-of-band" (not in > > ps->ps_siginfo). > >=20 > > We can't postpone sigdflt() to be called after signal being delivered, > > since spec requires it to be done before calling user-space handler. > > No, userspace is not called from sv_sendsig(), it simply cannot work > because nested signals would cause nesting on the kernel stack frame. > sv_sendsig() only prepares the usermode signal stack frame and arranges > the saved thread CPU state so that on return from kernel to usermode, > the signal handler is executed. So, if we rearrange calls to sv_sendsig() and sigdflt() there can't be cases when the process being signalled will pick the signal before sigdflt() will be called? Just because XSI wants that handler reset and clearing of SIGINFO happen before handler execution, http://pubs.opengroup.org/onlinepubs/009695399/functions/sigaction.html So, I went into more trouble of not touching the order. > And, amusingly, the only thing which sv_sendsig() methods need and which > is also touched by sigdflt(), is ps_siginfo. Simply rearranging the > order of calls should be enough. I put the patch at the end of message, > it worked for me. If there is no change in behaviour that will arise from rearranging the order of calls to mach-dependent and mach-independent code, I'd go a bit firther and unify some repeated code, http://codelabs.ru/fbsd/patches/libthr/11-CURRENT-fix-SIGINFO-processing-= with-RESETHAND-v2.diff Works for me too, just tested with the same Squid installation. > > It works fine with virgin libthr and solves Squid restart problem. > > Will try to install it to more test machines and see if it will work > > as expected. Seems like a kernel regression test like the attached > > one will also be handy. >=20 > There are people who develop the regression suite(s) for FreeBSD. > Might be, they would note your test, may be, you should somehow contact > them and propose the inclusion of the test into suite. I believe > it is freebsd-testing@f.o. The test would require adoption to the > framework. Yep, will try to catch this train. Thanks! --=20 Eygene Ryabinkin ,,,^..^,,, [ Life's unfair - but root password helps! | codelabs.ru ] [ 82FE 06BC D497 C0DE 49EC 4FF0 16AF 9EAE 8152 ECFB | freebsd.org ] --tsOsTdHNUZQcU9Ye Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (FreeBSD) iL4EABEKAGYFAlRvmMtfFIAAAAAALgAoaXNzdWVyLWZwckBub3RhdGlvbnMub3Bl bnBncC5maWZ0aGhvcnNlbWFuLm5ldDgyRkUwNkJDRDQ5N0MwREU0OUVDNEZGMDE2 QUY5RUFFODE1MkVDRkIACgkQFq+eroFS7PsUjwD9E4An7To8hTMjMj/AB0U9CaIU zMOtGJIujMTyXOWOFwUA/29vGNznci41I8RI2hFoZENcJtxjPr0nvABZyevYs7Yx =SAqx -----END PGP SIGNATURE----- --tsOsTdHNUZQcU9Ye--