From owner-freebsd-bugs Sat Mar 30 9:40:26 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (unknown [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 3CCB137B416 for ; Sat, 30 Mar 2002 09:40:16 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g2UHe1u13066; Sat, 30 Mar 2002 09:40:01 -0800 (PST) (envelope-from gnats) Received: from freefall.freebsd.org (unknown [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id BB2A637B416 for ; Sat, 30 Mar 2002 09:38:43 -0800 (PST) Received: (from nobody@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g2UHcbs12872; Sat, 30 Mar 2002 09:38:37 -0800 (PST) (envelope-from nobody) Message-Id: <200203301738.g2UHcbs12872@freefall.freebsd.org> Date: Sat, 30 Mar 2002 09:38:37 -0800 (PST) From: Gurusamy Sarathy To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-1.0 Subject: kern/36539: installing a SIGCHLD handler makes libc_r coredump Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 36539 >Category: kern >Synopsis: installing a SIGCHLD handler makes libc_r coredump >Confidential: no >Severity: critical >Priority: high >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Mar 30 09:40:01 PST 2002 >Closed-Date: >Last-Modified: >Originator: Gurusamy Sarathy >Release: 4.2 >Organization: ActiveState Corp. >Environment: FreeBSD clamp 4.2-RELEASE FreeBSD 4.2-RELEASE #0: Mon Nov 20 13:02:55 GMT 2000 jkh@bento.FreeBSD.org:/usr/src/sys/compile/GENERIC i386 >Description: The test case should be self-explanatory. % cc -g -o sig sig.c % ./sig Fatal error '_pq_remove: Not in priority queue' at line ? in file /usr/src/lib/libc_r/uthread/uthread_priority_queue.c (errno = ?) Abort (core dumped) % gdb ./sig ./sig.core GNU gdb 4.18 Copyright 1998 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-unknown-freebsd"... Core was generated by `sig'. Program terminated with signal 6, Abort trap. Reading symbols from /usr/lib/libc_r.so.4...done. Reading symbols from /usr/libexec/ld-elf.so.1...done. #0 0x280a4320 in kill () from /usr/lib/libc_r.so.4 (gdb) bt #0 0x280a4320 in kill () from /usr/lib/libc_r.so.4 #1 0x280ee6a6 in abort () from /usr/lib/libc_r.so.4 #2 0x280baffd in _thread_exit () from /usr/lib/libc_r.so.4 #3 0x280b440e in _pq_remove () from /usr/lib/libc_r.so.4 #4 0x280b6cb5 in _thread_kern_scheduler () from /usr/lib/libc_r.so.4 #5 0x0 in ?? () (gdb) q >How-To-Repeat: /* * Demonstrate crash in libc when a SIGCHLD handler is installed * either using sigaction() or signal() on FreeBSD 4.2-RELEASE. * * This program has different behavior when built with and without * -pthread. When built with -pthread, it will coredump somewhere * in libc's uthread_priority_queue.c after running for a few * seconds. * * Build with: * cc -g -o sig sig.c -pthread */ #include #include #include #include #include #include #include void reaper(int sig) { int status; pid_t pid; int save_errno = errno; while ((pid = waitpid(-1, &status, WNOHANG)) > 0) ; errno = save_errno; return; } int main(int ac, char **av) { struct sigaction sa; sa.sa_handler = reaper; sa.sa_flags = 0; sigemptyset(&sa.sa_mask); sigaction(SIGCHLD,&sa,NULL); /*signal(SIGCHLD,reaper);*/ /* this has the same problem */ /*syscall(SYS_sigaction,SIGCHLD,&sa,NULL);*/ /* workaround */ while (1) { pid_t c = fork(); if (c < 0) { fprintf(stderr, "fork() failed: %s\n", strerror(errno)); exit(1); } if (!c) { exit(0); } usleep(1); /* slow down, don't make too many children */ } } >Fix: None known. See workaround mentioned in the test case. >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message