[PATCH v8] linux: Do not spawn a new thread for SIGEV_THREAD (BZ 30558, 27895, 29705, 32833)
Carlos O'Donell
carlos@redhat.com
Wed Jul 8 20:04:57 GMT 2026
On 7/8/26 3:45 PM, Adhemerval Zanella Netto wrote:
>
>
> 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.
Agreed, this means the test needs -fasynchronous-unwind-tables.
$ grep -r 'fasynchronous' * | grep tst
debug/Makefile:CFLAGS-tst-longjmp_chk.c += -fexceptions -fasynchronous-unwind-tables
debug/Makefile:CFLAGS-tst-longjmp_chk2.c += -fexceptions -fasynchronous-unwind-tables
debug/Makefile:CFLAGS-tst-longjmp_chk3.c += -fexceptions -fasynchronous-unwind-tables
rt/Makefile:CFLAGS-tst-timer8.c += -fexceptions -fasynchronous-unwind-tables
sysdeps/pthread/Makefile:CFLAGS-tst-cancelx20.c += -fexceptions -fasynchronous-unwind-tables
sysdeps/pthread/Makefile:CFLAGS-tst-cancelx21.c += -fexceptions -fasynchronous-unwind-tables
sysdeps/pthread/Makefile:CFLAGS-tst-cleanupx0.c += -fexceptions -fasynchronous-unwind-tables
sysdeps/pthread/Makefile:CFLAGS-tst-cleanupx1.c += -fexceptions -fasynchronous-unwind-tables
sysdeps/unix/sysv/linux/Makefile:CFLAGS-tst-sigcontext-get_pc.c = -fasynchronous-unwind-tables
Which we already use for other similar tests.
> 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.
Right, I think we could use atomics here just to avoid futex too and make the
regression test simpler and conforming.
--
Cheers,
Carlos.
More information about the Libc-alpha
mailing list