[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:28:48 +0300 |
On Thu, May 11, 2023 at 9:12 PM Florian Weimer <fweimer@redhat.com> wrote:
> I'd expect __pthread_setcancelstate to act on asynchronous cancellation
> if it is enabled. Once you implement that and have a strong symbol
> reference to __pthread_setcancelstate, you'd pull in the cancellation
> unwinder without additional measures, and this would into every program.
> You probably don't want that. So the reference to the core cancellation
> had better be weak (or use the __libc_ptf_call indirection).
>
> Does this answer your question? Sorry, these static linking size
> optimizations are tricky.
I think it does, thank you!
As for unwinding: it appears that that htl does call the cleanup
handlers, but without any actual unwinding. It just does this:
for (handlers = __pthread_get_cleanup_stack ();
*handlers != NULL;
*handlers = (*handlers)->__next)
(*handlers)->__handler ((*handlers)->__arg);
where __pthread_get_cleanup_stack just returns
&__pthread_cleanup_stack. So if we add this immediate cancellation &
cleanup logic to __pthread_setcancelstate, it shouldn't pull in much.
Do user programs in practice rely on the fact that pthread
cancellation does unwinding and so calls object destructors, runs
@finally clauses, etc?
Sergey