Re: [PATCH v8] linux: Do not spawn a new thread for SIGEV_THREAD (BZ 30558, 27895, 29705, 32833)

Adhemerval Zanella Netto <[email protected]>
Newsgroups gmane.comp.lib.glibc.alpha
Organization Linaro
Message-ID <[email protected]>

On 08/07/26 15:05, Carlos O'Donell wrote:
> On 7/7/26 11:59 AM, Adhemerval Zanella wrote:
>> The current timer_create SIGEV_THREAD implementation has some
>> downsides:
> 
> Test rt/tst-timer8.c fails if pause() is removed indicating something is
> wrong with the asynchronous cancellation.
> 
> Note that pause() should be removed because it's a cancellation point
> which causes the thread to test for cancellation, and it will see the
> bits set by pthread_cancel and cancel.
> 
> I don't know why the newe implementation fails to cancel the thread, I just
> know that without pause it should still cancel but doesn't.
It is because the test is built with -fexception and gcc gives the notification
function a DWARF/LSDA unwind whose cleanup actions exist only at call sites.
Asynchronous cancellation that interrupts a PC not inside any call-site region
finds no landing pad there (the while (1)), so the personality routine performs 
no cleanup for that frame (the on_cancel registered with pthread_cleanup_push)
and the unwind proceeds straight to thread termination.

And as you noted privately the sem_post called by on_cancel is strictly UB,
I will change to use a different synchronization mechanism to check whether
the cancellation was acted upon.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.