Skip to content

test: interrupt: handle signals when cancelled

During cancellation, signals can be sent to the threads to interrupt the syscalls, leading to spurrious failure of the test depending on when vlc_cancel race against poll().

With ASAN enabled, I typically got almost 100% reproductibility of vlc_poll_i11e returning -1 with errno=EINTR, with a non-interrupted context, in the cancelled thread test. Note that it can also be reproduced without ASAN but less often.

Since we have a test without thread cancellation, allow EINTR in the thread cancellation scenario to check that timeout can still happen.

strace -f --trace=%signal,poll,write,read build/src/test_interrupt
...
strace: Process 421456 attached
[pid 421453] rt_sigprocmask(SIG_SETMASK, [INT QUIT PIPE TERM], NULL, 8) = 0
[pid 421456] rt_sigprocmask(SIG_SETMASK, [INT QUIT PIPE TERM],  <unfinished ...>
[pid 421453] rt_sigprocmask(SIG_SETMASK, [],  <unfinished ...>
[pid 421456] <... rt_sigprocmask resumed>NULL, 8) = 0
[pid 421453] <... rt_sigprocmask resumed>NULL, 8) = 0
[pid 421453] rt_sigaction(SIGRTMIN, {sa_handler=0x7fafedcdaa80, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART|SA_SIGINFO, sa_restorer=0x7fafedc91560}, NULL, 8) = 0
[pid 421453] rt_sigprocmask(SIG_BLOCK, ~[], [], 8) = 0
[pid 421453] tgkill(421453, 421456, SIGRTMIN) = 0
[pid 421456] poll([{fd=5, events=POLLIN}], 1, 1 <unfinished ...>
[pid 421453] rt_sigprocmask(SIG_SETMASK, [],  <unfinished ...>
[pid 421456] <... poll resumed>)        = ? ERESTART_RESTARTBLOCK (Interrupted by signal)
[pid 421453] <... rt_sigprocmask resumed>NULL, 8) = 0
[pid 421456] --- SIGRTMIN {si_signo=SIGRTMIN, si_code=SI_TKILL, si_pid=421453, si_uid=1000} ---
[pid 421456] rt_sigreturn({mask=[INT QUIT PIPE TERM]}) = -1 EINTR (Interrupted system call)
[pid 421456] write(2, "test_interrupt: ../../src/test/i"..., 119test_interrupt: ../../src/test/interrupt.c:86: test_context_simple: Assertion `vlc_poll_i11e(NULL, 0, 1) == 0' failed.
) = 119
[pid 421456] rt_sigprocmask(SIG_UNBLOCK, [ABRT], NULL, 8) = 0
[pid 421456] tgkill(421453, 421456, SIGABRT) = 0
[pid 421456] --- SIGABRT {si_signo=SIGABRT, si_code=SI_TKILL, si_pid=421453, si_uid=1000} ---
[pid 421456] +++ killed by SIGABRT (core dumped) +++
+++ killed by SIGABRT (core dumped) +++

Fix #26488 (closed)

Merge request reports