From nobody@FreeBSD.org Sun Dec 19 17:20:54 2004 Return-Path: Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 85A7816A4CE for ; Sun, 19 Dec 2004 17:20:54 +0000 (GMT) Received: from www.freebsd.org (www.freebsd.org [216.136.204.117]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5F2AB43D41 for ; Sun, 19 Dec 2004 17:20:54 +0000 (GMT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.13.1/8.13.1) with ESMTP id iBJHKs1e081820 for ; Sun, 19 Dec 2004 17:20:54 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.13.1/8.13.1/Submit) id iBJHKs0R081818; Sun, 19 Dec 2004 17:20:54 GMT (envelope-from nobody) Message-Id: <200412191720.iBJHKs0R081818@www.freebsd.org> Date: Sun, 19 Dec 2004 17:20:54 GMT From: "Enoch W." To: freebsd-gnats-submit@FreeBSD.org Subject: FBSD 5.3 libpthread (KSE) bug X-Send-Pr-Version: www-2.3 >Number: 75273 >Category: threads >Synopsis: FBSD 5.3 libpthread (KSE) bug >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-threads >State: closed >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Dec 19 17:30:26 GMT 2004 >Closed-Date: Sun May 02 21:25:37 UTC 2010 >Last-Modified: Sun May 02 21:25:37 UTC 2010 >Originator: Enoch W. >Release: FreeBSD 5.3-STABLE >Organization: >Environment: __FreeBSD_version 503101 i386 >Description: sigsuspend() bug Thread aborts at /usr/src/lib/libpthread/thread/thr_sigsuspend.c line 77 with "oldsigmask is not cleared" when the main thread tries to pthread_cancel() it. FreeBSD 4.x (libc_r) does not have this problem. >How-To-Repeat: >Fix: The easy solution :-) remove: THR_ASSERT(curthread->oldsigmask == NULL, "oldsigmask is not cleared"); >Release-Note: >Audit-Trail: From: Daniel Eischen To: "Enoch W." Cc: freebsd-gnats-submit@freebsd.org Subject: Re: threads/75273: FBSD 5.3 libpthread (KSE) bug Date: Sun, 19 Dec 2004 12:54:54 -0500 (EST) On Sun, 19 Dec 2004, Enoch W. wrote: > >Description: > sigsuspend() bug > > Thread aborts at /usr/src/lib/libpthread/thread/thr_sigsuspend.c line 77 with "oldsigmask is not cleared" when the main thread tries to pthread_cancel() it. > > FreeBSD 4.x (libc_r) does not have this problem. > > >How-To-Repeat: > > >Fix: > The easy solution :-) remove: > THR_ASSERT(curthread->oldsigmask == NULL, "oldsigmask is not cleared"); Sample program to demonstrate the problem, please? This could be fixed in -current, but since I don't know how to repeat the problem, I can't test it. From: "Enoch W." To: , Cc: Subject: Re: threads/75273: FBSD 5.3 libpthread (KSE) bug Date: Tue, 21 Dec 2004 23:26:28 -0500 This is a multi-part message in MIME format. ------=_NextPart_000_0002_01C4E7B4.7F0A0870 Content-Type: multipart/alternative; boundary="----=_NextPart_001_0003_01C4E7B4.7F0B8F10" ------=_NextPart_001_0003_01C4E7B4.7F0B8F10 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Problem demo is attached, as requested. TIA, Enoch. ------=_NextPart_001_0003_01C4E7B4.7F0B8F10 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Problem demo is attached, as requested. = TIA,=20 Enoch.
------=_NextPart_001_0003_01C4E7B4.7F0B8F10-- ------=_NextPart_000_0002_01C4E7B4.7F0A0870 Content-Type: application/octet-stream; name="demo.c" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="demo.c" #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= =0A= #define ASSRET(cond) do { \=0A= if (!(cond)) { \=0A= fprintf(stderr, "ASSRET ERROR @ %d -> %s\n", __LINE__, \=0A= strerror(ret =3D=3D -1 ? errno : ret)); \=0A= exit(EXIT_FAILURE); \=0A= } \=0A= } while (0)=0A= =0A= int tock;=0A= =0A= void tick()=0A= {=0A= tock =3D 1;=0A= }=0A= =0A= void *pulse(void *arg)=0A= {=0A= int ret;=0A= struct itimerval it;=0A= sigset_t set;=0A= =0A= sigemptyset(&set);=0A= sigaddset(&set, SIGALRM);=0A= ret =3D sigprocmask(SIG_BLOCK, &set, NULL);=0A= ASSRET(ret =3D=3D 0);=0A= sigemptyset(&set);=0A= =0A= it.it_interval.tv_sec =3D 1;=0A= it.it_interval.tv_usec =3D 0;=0A= it.it_value.tv_sec =3D 1;=0A= it.it_value.tv_usec =3D 0;=0A= ret =3D setitimer(ITIMER_REAL, &it, NULL);=0A= ASSRET(ret =3D=3D 0);=0A= =0A= while (1) {=0A= while (!tock)=0A= sigsuspend(&set);=0A= tock =3D 0;=0A= putchar('*');=0A= fflush(stdout);=0A= }=0A= }=0A= =0A= int main()=0A= {=0A= int ret;=0A= pthread_attr_t attr;=0A= pthread_t thread;=0A= =0A= ret =3D pthread_attr_init(&attr);=0A= ASSRET(ret =3D=3D 0);=0A= ret =3D pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);=0A= ASSRET(ret =3D=3D 0);=0A= =0A= signal(SIGALRM, tick);=0A= =0A= ret =3D pthread_create(&thread, NULL, pulse, NULL);=0A= ASSRET(ret =3D=3D 0);=0A= =0A= printf("Press Enter to cancel the pulse() thread\n");=0A= while (getchar() !=3D '\n');=0A= =0A= ret =3D pthread_cancel(thread);=0A= ASSRET(ret =3D=3D 0);=0A= ret =3D pthread_join(thread, NULL);=0A= ASSRET(ret =3D=3D 0);=0A= =0A= printf("Press Enter to end\n");=0A= while (getchar() !=3D '\n');=0A= return 0;=0A= }=0A= ------=_NextPart_000_0002_01C4E7B4.7F0A0870 Content-Type: application/octet-stream; name="demo.mk" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="demo.mk" demo: demo.c=0A= $(CC) -Wall -g -odemo -pthread demo.c=0A= ------=_NextPart_000_0002_01C4E7B4.7F0A0870-- From: Craig Rodrigues To: freebsd-gnats-submit@freebsd.org Cc: ixew@hotmail.com Subject: Re: threads/75273: FBSD 5.3 libpthread (KSE) bug Date: Wed, 22 Dec 2004 01:05:04 -0500 Here is the non-MIME mangled version of the demo source. It works for me on -CURRENT. #include #include #include #include #include #include #define ASSRET(cond) do { \ if (!(cond)) { \ fprintf(stderr, "ASSRET ERROR @ %d -> %s\n", __LINE__, \ strerror(ret == -1 ? errno : ret)); \ exit(EXIT_FAILURE); \ } \ } while (0) int tock; void tick() { tock = 1; } void *pulse(void *arg) { int ret; struct itimerval it; sigset_t set; sigemptyset(&set); sigaddset(&set, SIGALRM); ret = sigprocmask(SIG_BLOCK, &set, NULL); ASSRET(ret == 0); sigemptyset(&set); it.it_interval.tv_sec = 1; it.it_interval.tv_usec = 0; it.it_value.tv_sec = 1; it.it_value.tv_usec = 0; ret = setitimer(ITIMER_REAL, &it, NULL); ASSRET(ret == 0); while (1) { while (!tock) sigsuspend(&set); tock = 0; putchar('*'); fflush(stdout); } } int main() { int ret; pthread_attr_t attr; pthread_t thread; ret = pthread_attr_init(&attr); ASSRET(ret == 0); ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); ASSRET(ret == 0); signal(SIGALRM, tick); ret = pthread_create(&thread, NULL, pulse, NULL); ASSRET(ret == 0); printf("Press Enter to cancel the pulse() thread\n"); while (getchar() != '\n'); ret = pthread_cancel(thread); ASSRET(ret == 0); ret = pthread_join(thread, NULL); ASSRET(ret == 0); printf("Press Enter to end\n"); while (getchar() != '\n'); return 0; } From: Craig Rodrigues To: freebsd-gnats-submit@freebsd.org Cc: "Enoch W." Subject: Re: threads/75273: FBSD 5.3 libpthread (KSE) bug Date: Wed, 22 Dec 2004 13:18:52 -0500 On Wed, Dec 22, 2004 at 06:10:24AM +0000, Craig Rodrigues wrote: > Here is the non-MIME mangled version of the demo source. > It works for me on -CURRENT. While this testcase does not fail on -CURRENT, I just verified that it does in fact fail on 5.3 with: Press Enter to cancel the pulse() thread ****** Fatal error 'oldsigmask is not cleared' at line 77 in file /usr/src/lib/libpthread/thread/thr_sigsuspend.c (errno = 4) Abort trap (core dumped) -- Craig Rodrigues rodrigc@crodrigues.org State-Changed-From-To: open->closed State-Changed-By: jilles State-Changed-When: Sun May 2 21:25:36 UTC 2010 State-Changed-Why: This was fixed before 6.0 in r139052. I cannot reproduce it on 7.x (libthr/libkse), 8.x and 9.x either. http://www.freebsd.org/cgi/query-pr.cgi?pr=75273 >Unformatted: