[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: __pthread_setcancelstate called unconditionally, crashes at 0

From: Sergey Bugaev
Subject: Re: __pthread_setcancelstate called unconditionally, crashes at 0
Date: Thu, 11 May 2023 21:00:14 +0300

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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]