mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: Florian Weimer <fweimer@redhat.com>
Cc: musl@lists.openwall.com
Subject: Re: sigaltstack for implementation-internal signals?
Date: Wed, 6 Mar 2019 13:03:28 -0500	[thread overview]
Message-ID: <20190306180328.GT23599@brightrain.aerifal.cx> (raw)
In-Reply-To: <87o96napgb.fsf@oldenburg2.str.redhat.com>

On Wed, Mar 06, 2019 at 06:21:40PM +0100, Florian Weimer wrote:
> * Rich Felker:
> 
> > For pthread_cancel, it's asynchronous. The signal can be blocked if
> > the cancellation signal handler has already run and determined that it
> > should not act on cancellation (disabled or not at a cancellation
> > point); in that case, it re-raises the signal and leaves it pending,
> > so that, if the determination was made while the thread was executing
> > a signal handler, it can re-evaluate when the signal handler returns
> > (possibly into restarting a blocking syscall that's a cancellation
> > point). I don't see any easy way to make this synchronous with respect
> > to the thread calling pthread_cancel, but maybe there is by breaking
> > it down into cases and using more than one signal.
> 
> phtread_cancel is slightly different; I think think we can send a signal
> for that.  It can't be made synchronous because if we block the
> canceling thread while the canceled thread unwinds (running cancellation
> handlers), we will probably end up introducing deadlocks involving
> application locks.

If not for the "re-raise a signal" aspect I described, you could do it
"synchronously". You don't have to wait for the cleanup functions to
run. Rather, you'd just wait for the target thread to exit the base
cancellation logic code, respond with an indication of what it's
doing, and get off the new stack. If acting on the cancellation, it
would modify the ucontext it's returning to with a new call frame on
it's main stack to run the unwind/cleanup in, then return.

Rich


  reply	other threads:[~2019-03-06 18:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-05 15:57 Rich Felker
2019-03-06 12:56 ` Florian Weimer
2019-03-06 15:54   ` Rich Felker
2019-03-06 17:21     ` Florian Weimer
2019-03-06 18:03       ` Rich Felker [this message]
2019-03-06 16:07   ` Markus Wichmann
2019-03-06 16:25     ` Rich Felker
     [not found]       ` <20190306171119.GG28106@voyager>
2019-03-06 18:20         ` Rich Felker

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=20190306180328.GT23599@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=fweimer@redhat.com \
    --cc=musl@lists.openwall.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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).