public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug nptl/10815] New: [timer_create / SIGEV_THREAD] signalmask of timer_sigev_thread dangerous
@ 2009-10-20 10:11 roland dot lezuo at chello dot at
  2009-10-20 11:31 ` [Bug nptl/10815] " drepper at redhat dot com
  0 siblings, 1 reply; 2+ messages in thread
From: roland dot lezuo at chello dot at @ 2009-10-20 10:11 UTC (permalink / raw)
  To: glibc-bugs

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.

<snip>
/* 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;
<snap>

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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug nptl/10815] [timer_create / SIGEV_THREAD] signalmask of timer_sigev_thread dangerous
  2009-10-20 10:11 [Bug nptl/10815] New: [timer_create / SIGEV_THREAD] signalmask of timer_sigev_thread dangerous roland dot lezuo at chello dot at
@ 2009-10-20 11:31 ` drepper at redhat dot com
  0 siblings, 0 replies; 2+ messages in thread
From: drepper at redhat dot com @ 2009-10-20 11:31 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From drepper at redhat dot com  2009-10-20 11:31 -------
The behavior is correct.  You're relying on undefined behavior.  Just don't do it.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WONTFIX


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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-10-20 11:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-20 10:11 [Bug nptl/10815] New: [timer_create / SIGEV_THREAD] signalmask of timer_sigev_thread dangerous roland dot lezuo at chello dot at
2009-10-20 11:31 ` [Bug nptl/10815] " drepper at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).