Date: Thu, 21 Nov 2013 14:39:02 +0200 From: Vitaly Magerya <vmagerya@gmail.com> To: freebsd-hackers@freebsd.org Subject: Problem with signal 0 being delivered to SIGUSR1 handler Message-ID: <528DFEE6.6020504@gmail.com>
next in thread | raw e-mail | index | archive | help
Hi, folks. I'm investigating a test case failure that devel/boehm-gc has on recent FreeBSD releases. The problem is that a signal handler registered for SIGUSR1 is sometimes called with signum=0, which should not be possible under any conditions. Here's a simple test case that demonstrates this behavior: /* Compile with 'c99 -o example example.c -pthread' */ #include <pthread.h> #include <signal.h> #include <stdio.h> #include <stdlib.h> void signal_handler(int signum, siginfo_t *si, void *context) { if (signum != SIGUSR1) { printf("bad signal, signum=%d\n", signum); exit(1); } } void *thread_func(void *arg) { return arg; } int main(void) { struct sigaction sa = { 0 }; sa.sa_flags = SA_SIGINFO; sa.sa_sigaction = signal_handler; if (sigfillset(&sa.sa_mask) != 0) abort(); if (sigaction(SIGUSR1, &sa, NULL) != 0) abort(); for (int i = 0; i < 10000; i++) { pthread_t t; pthread_create(&t, NULL, thread_func, NULL); pthread_kill(t, SIGUSR1); } return 0; } Under FreeBSD 9.2-RELEASE amd64 I pretty consistently get "signum=0" from this program, but you may need to run it a few times or increase the number of iterations to see the same. Interestingly enough, I don't see this behavior under 9.0-RELEASE. So, any ideas what the problem here is?
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?528DFEE6.6020504>