Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Nov 2013 20:39:42 +0200
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Jilles Tjoelker <jilles@stack.nl>
Cc:        freebsd-hackers@freebsd.org, threads@freebsd.org, Vitaly Magerya <vmagerya@gmail.com>, davidxu@freebsd.org
Subject:   Re: Problem with signal 0 being delivered to SIGUSR1 handler
Message-ID:  <20131122183942.GB59496@kib.kiev.ua>
In-Reply-To: <20131122133553.GA28457@stack.nl>
References:  <528DFEE6.6020504@gmail.com> <20131121211546.GQ59496@kib.kiev.ua> <20131122133553.GA28457@stack.nl>

next in thread | previous in thread | raw e-mail | index | archive | help

--rmx1G5GNWS01lHd9
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Fri, Nov 22, 2013 at 02:35:53PM +0100, Jilles Tjoelker wrote:
> This analysis suggests an easier approach: just move the check for
> deferred_siginfo.si_signo =3D=3D 0 downward. If __fillcontextx2 or sysarch
> need to be looked up by rtld, the resulting _thr_ast() will invoke the
> signal handler and the original call to check_deferred_signal() will do
> nothing.
>=20
> This patch fixes the problem for me on stable/9 and head.
>=20
> Index: lib/libthr/thread/thr_sig.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- lib/libthr/thread/thr_sig.c	(revision 258178)
> +++ lib/libthr/thread/thr_sig.c	(working copy)
> @@ -326,12 +326,12 @@ check_deferred_signal(struct pthread *curthread)
>  	uc_len =3D __getcontextx_size();
>  	uc =3D alloca(uc_len);
>  	getcontext(uc);
> -	if (curthread->deferred_siginfo.si_signo =3D=3D 0)
> -		return;
>  	__fillcontextx2((char *)uc);
>  	act =3D curthread->deferred_sigact;
>  	uc->uc_sigmask =3D curthread->deferred_sigmask;
>  	memcpy(&info, &curthread->deferred_siginfo, sizeof(siginfo_t));
> +	if (curthread->deferred_siginfo.si_signo =3D=3D 0)
> +		return;
>  	/* remove signal */
>  	curthread->deferred_siginfo.si_signo =3D 0;
>  	handle_signal(&act, info.si_signo, &info, uc);
>=20

I do not like this. It is similar to what I did initially when I
debugged the problem, but the duplicated calls to getcontext(2) and
sysarch(2) stayed out as a sore in ktrace. I also do not like the fact
that, with the change, signal is delivered from an rtld context.

If taking such road, the fix would be to add __fillcontext2() to
_rtld_init(), but I described the reason for other fix in the initial
response.

--rmx1G5GNWS01lHd9
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (FreeBSD)

iQIcBAEBAgAGBQJSj6TtAAoJEJDCuSvBvK1BOSkQAIgX0yy3jpTylGEV1X5BfvRt
SkbpN+JlzSgUTMKGrnA0qt03SQE2JZp9rHS+b8qPEgDuXG/P76pz10rqcMF+3wv3
4Xs9yiv0r4kRv9Blw7d5tvsXi1HH9sF8hPmj2TbL2rJ1qOv4hacg5LLvocyZZ4oz
yyL5WRB6XwQTW3Ax8BXSMuxLvHA4P2PAQ6CxG2283O1WQrOHELroLGTeS1nCvjaI
irefCxx5lXWS3HYi6NxkV6MWIBYI7e57tLZNAKJnF5FDT8bWw/0hqR1/8Jpp/80Y
vEs/56f1yNzJibzTS84NmZ5iW5KsKC4NR/Oq3AyRgZQ65C6Du2oOyHgjDW7o6a+i
JznvcXVGA4TlF0m2e0zoXAhG0uHtxKZaHeDm8MBrR2ghZY2w1o2IHxIW944yzzY4
wkHT3i2WsMVkpPqyIMr2Zb4Z/tKf9bnthk3K3+JnTbSJDnvpzU2xIU3B1iosmXM2
GRKBCwzD36MzJ0MBZWbSWtpdJZDcS+qZVyJviq3TKsqd0Tfbr+08LtkXJ8w+3gDV
de4RMbNc9cqN9hq+mvvTxdZKUd4nFYuwZXx0qyUxZequ16tYpUfAXlnaVco6vYAS
5fFc1ztq+lVhjkLnGeW+SE1q4Alju6cgAnf25XUo+7W3ZEtC+DxXnrtuptpzcJ3X
XZLeWMJ+5fuwTle9w9SP
=pWVY
-----END PGP SIGNATURE-----

--rmx1G5GNWS01lHd9--



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