Subject: Re: -current and libpthread and signals
To: Stephan Thesing <thesing@cs.uni-sb.de>
From: Bill Studenmund <wrstuden@netbsd.org>
List: current-users
Date: 05/10/2004 15:37:10
--dc+cDN39EJAMEtIO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, May 06, 2004 at 11:29:35PM +0200, Stephan Thesing wrote:
> Hi,
>=20
> I noticed that signal delivery has problems with a Qt application that us=
es the
> QProcess class and thus creates and destroys threads and receives SIGCHLD=
 when
> a child _process_ has exited (internally in Qt the QProcess class install=
s a
> signal handler for SIGCHLD and from the handler triggers the Qt notificat=
ion
> mechanism).
>=20
> The symptoms are either
>  - the signal is never delivered to a thread, as all living threads have =
it
>    blocked in their signal masks
>=20
> or
>  - with PTHREAD_CONCURRENCY=3D2, an assertion in libpthreads triggers whe=
n a
>    signal is tried to be delivered to a running thread:
>    assertion "target->pt_state !=3D PT_STATE_RUNNING || target->pt_blockg=
en !=3D
>    target->pt_unblockgen" failed: file "/usr/src/lib/libpthread/pthread_s=
ig.c",
>    line 794, function "pthread__kill"
>=20
> [ The first case may be because at the time the signal is delivered, it is
>   blocked in all but one thread. Unfortunately, the thread that has the s=
ignal
>   pending, exits before the signal handler can be taken. As the signal re=
mains
>   blocked in all other threads, the handler is never invoked.
>   (Which is just my impression after ooking at some debug output of libpt=
hread,
>   without pretending I understand the code and interna of the pthread lib=
rary)
> ]

This issue, if correct, seems like a library bug. If you are going to ask=
=20
for SIGCHLD, you should have something to receive it.

I'm not sure what the right behavior is if you get a signal (that you=20
requested) and nothing can receive it.

> I am just curious if this behavior is known and on somebodys TODO list....
>=20
> If more input is needed to fix this behavior I can try to construct a sma=
ller
> example program that triggers it (the original application is quite large=
 and
> propietary source code..)....

Unfortunately I am not a person to work on this. However if you could make=
=20
a simpler test, that would be great. It could even be added as a=20
regression test.

Take care,

Bill

--dc+cDN39EJAMEtIO
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (NetBSD)

iD8DBQFAoAQWWz+3JHUci9cRAp3XAJ4i9P95U0G/+qYjpwblaYb+MiFkKACgmLWo
kYEDajI8/22hg7zAXilSnwA=
=CO62
-----END PGP SIGNATURE-----

--dc+cDN39EJAMEtIO--