Date: Sat, 30 Mar 2002 09:38:37 -0800 (PST) From: Gurusamy Sarathy <gsar@ActiveState.com> To: freebsd-gnats-submit@FreeBSD.org Subject: kern/36539: installing a SIGCHLD handler makes libc_r coredump Message-ID: <200203301738.g2UHcbs12872@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>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 <stdio.h> #include <signal.h> #include <errno.h> #include <unistd.h> #include <sys/syscall.h> #include <sys/types.h> #include <sys/wait.h> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200203301738.g2UHcbs12872>