From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28243 invoked by alias); 20 Oct 2009 10:11:57 -0000 Received: (qmail 27890 invoked by uid 48); 20 Oct 2009 10:11:44 -0000 Date: Tue, 20 Oct 2009 10:11:00 -0000 From: "roland dot lezuo at chello dot at" To: glibc-bugs@sources.redhat.com Message-ID: <20091020101143.10815.roland.lezuo@chello.at> Reply-To: sourceware-bugzilla@sourceware.org Subject: [Bug nptl/10815] New: [timer_create / SIGEV_THREAD] signalmask of timer_sigev_thread dangerous X-Bugzilla-Reason: CC Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-owner@sourceware.org X-SW-Source: 2009-10/txt/msg00046.txt.bz2 When a POSIX timer is created with timer_create and sigev_notify = SIGEV_THREAD glibc uses internal helper threads (timer_sigev_thread) to invoke the callback function. This helper threads unblocks all signals. /* Helper thread to call the user-provided function. */ static void * timer_sigev_thread (void *arg) { /* The parent thread has all signals blocked. This is a bit surprising for user code, although valid. We unblock all signals. */ sigset_t ss; sigemptyset (&ss); INTERNAL_SYSCALL_DECL (err); INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_SETMASK, &ss, NULL, _NSIG / 8); struct thread_start_data *td = (struct thread_start_data *) arg; According to the POSIX standard the signalmask of the thread executing the timer callback is implementation defined. The above comments indicates that the signal mask is cleared to not suprise user code. I have an application which uses multiple rt-signals. One of them is blocked by all threads and received using sigwaitinfo. The behaviour of timer_sigev_thread opens a race condition where the rt-signal is delivered and because there is no signal handler the application crashes. It is unfeasible to add a signal handler and propagate the event back to the signal handling code. I did not actually try on FreeBSD, but it seems they do not clear the signalmask. I think the correct way is to assume worst and have the signalmask blocking all signals. User code must be prepared to be executed with any signalmask, and by doing so glibc does not crash user applications depending on blocked signals and sigwaitinfo. -- Summary: [timer_create / SIGEV_THREAD] signalmask of timer_sigev_thread dangerous Product: glibc Version: 2.9 Status: NEW Severity: normal Priority: P2 Component: nptl AssignedTo: drepper at redhat dot com ReportedBy: roland dot lezuo at chello dot at CC: glibc-bugs at sources dot redhat dot com http://sourceware.org/bugzilla/show_bug.cgi?id=10815 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.