Issue created by Sebastian Huber: 
https://gitlab.rtems.org/rtems/rtos/rtems/-/work_items/5824



With `RTEMS_POSIX_API` enabled, a POSIX signal sent to a thread which waits in 
`pthread_cond_wait()`, `pthread_cond_timedwait()` or `pthread_cond_clockwait()` 
does not interrupt the wait. The signal handler runs only after a 
`pthread_cond_signal()`, a `pthread_cond_broadcast()` or a timeout ends the 
wait. Without one of these, the signal is never delivered.

POSIX expects the handler to run during the wait: "If a signal is delivered to 
a thread waiting for a condition variable, upon return from the signal handler 
the thread resumes waiting for the condition variable as if it was not 
interrupted, or it shall return zero due to spurious wakeup." Linux runs the 
handler and resumes the wait.

Commit 7f4ee2b4ae3 ("posix: Avoid Giant lock for condition variables") dropped 
`STATES_INTERRUPTIBLE_BY_SIGNAL` from the wait state in 2016. 
`_POSIX_signals_Unblock_thread()` therefore leaves the thread blocked and only 
adds the post-switch action of the handler. The code in `condwaitsupp.c` which 
maps `EINTR` to a spurious wakeup has been dead since then.

`psxsignal06` expects the interrupted wait, see its `.scn` file. It checks 
nothing after the signal, so it passes also if the wait never returns.

This description was created with Claude Code assistance.

-- 
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/work_items/5824
You're receiving this email because of your account on gitlab.rtems.org. 
Unsubscribe from this thread: 
https://gitlab.rtems.org/-/namespace/49/sent_notifications/6-5ma1l617dyd4v460e9fvo24fu-1d/unsubscribe
 | Manage all notifications: https://gitlab.rtems.org/-/profile/notifications | 
Help: https://gitlab.rtems.org/help


_______________________________________________
bugs mailing list
[email protected]
http://lists.rtems.org/mailman/listinfo/bugs

Reply via email to