public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "bugdal at aerifal dot cx" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sources.redhat.com
Subject: [Bug nptl/14830] New: Race conditions with signals and thread priority scheduling
Date: Sun, 11 Nov 2012 20:50:00 -0000	[thread overview]
Message-ID: <bug-14830-131@http.sourceware.org/bugzilla/> (raw)

http://sourceware.org/bugzilla/show_bug.cgi?id=14830

             Bug #: 14830
           Summary: Race conditions with signals and thread priority
                    scheduling
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: nptl
        AssignedTo: unassigned@sourceware.org
        ReportedBy: bugdal@aerifal.cx
                CC: drepper.fsp@gmail.com
    Classification: Unclassified


NPTL implements thread priority scheduling for new threads by creating the new
thread but blocking its forward progress until pthread_create in the parent can
set the new thread's scheduling options. If this fails (e.g. due to EPERM),
pthread_create is required to fail. To achieve this result, NPTL has
pthread_create send a cancellation request to the new thread.

Unfortunately, NPTL fails to block signals during thread creation, so it's
possible that a signal handler is already running (at the wrong priority) in
the newly created thread by the time the failure to set the priority had been
detected. The cancellation request will then cause any cancellation-point
function called from the signal handler to act upon cancellation, possibly with
disastrous results if the application was not written to use cancellation.

I believe the simplest solution to this issue is to block all signals before
clone() is called. In the parent, signals can be unblocked immediately as soon
as clone returns. In the new thread, signals cannot be unblocked until it's
determined that the thread will be allowed to run.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


             reply	other threads:[~2012-11-11 20:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-11 20:50 bugdal at aerifal dot cx [this message]
2014-01-10 20:48 ` [Bug nptl/14830] " carlos at redhat dot com
2014-06-14 11:09 ` fweimer at redhat dot com
2021-05-27  0:32 ` adhemerval.zanella at linaro dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-14830-131@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).