public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Sergey Bugaev <bugaevc@gmail.com>
To: Florian Weimer <fweimer@redhat.com>
Cc: libc-alpha@sourceware.org, bug-hurd <bug-hurd@gnu.org>,
	 Samuel Thibault <samuel.thibault@gnu.org>
Subject: Re: __pthread_setcancelstate called unconditionally, crashes at 0
Date: Thu, 11 May 2023 21:00:14 +0300	[thread overview]
Message-ID: <CAN9u=Hfw6iF1wWAQ-4ST8OeM3O9t+f1KGfidgn+NJXX1Zo_7Xw@mail.gmail.com> (raw)
In-Reply-To: <87ilcyg3ud.fsf@oldenburg3.str.redhat.com>

On Thu, May 11, 2023 at 8:44 PM Florian Weimer <fweimer@redhat.com> wrote:
> Apparently, Hurd does not support async cancellation? Then
> __pthread_setcancelstate never has to unwind, so you just turn it into a
> non-weak symbol.

It does in theory, htl/pt-cancel.c has a PTHREAD_CANCEL_ASYNCHRONOUS
branch that calls into sysdeps/mach/hurd/htl/pt-docancel.c, which
manipulates the victim thread's state to make it call __pthread_exit
(0). (This is also implemented in a rather sad way that most likely
wouldn't work on x86_64-gnu; I'll get to fixing that some time...)

But it doesn't seem to either do any unwinding, nor is
__pthread_setcancelstate async-cancel-safe (it uses a mutex).

> If you need async cancellation support, the core cancellation routine
> could be made weak, so that it is linked into the executable only if
> pthread_cancel is ever called.

Could you please expand on how this all (unwinding, async
cancellation) is relevant? Clearly calling error () in a
PTHREAD_CANCEL_ASYNCHRONOUS context is undefined behavior since error
() is not async-cancel-safe.

Sergey

  parent reply	other threads:[~2023-05-11 18:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-11 17:31 Sergey Bugaev
2023-05-11 17:44 ` Florian Weimer
2023-05-11 17:52   ` Samuel Thibault
2023-05-11 17:56     ` Florian Weimer
2023-05-11 18:00   ` Sergey Bugaev [this message]
2023-05-11 18:12     ` Florian Weimer
2023-05-11 18:28       ` Sergey Bugaev
2023-05-11 18:35         ` Florian Weimer

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='CAN9u=Hfw6iF1wWAQ-4ST8OeM3O9t+f1KGfidgn+NJXX1Zo_7Xw@mail.gmail.com' \
    --to=bugaevc@gmail.com \
    --cc=bug-hurd@gnu.org \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=samuel.thibault@gnu.org \
    /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).