Aaditya Agarwal created a merge request: 
https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1601

Project:Branches: aaditya8979/rtems:fix-5819 to rtems/rtos/rtems:main
Author: Aaditya Agarwal

In `pthread_cond_timedwait()` and `pthread_cond_clockwait()`, the enqueue 
callout added the timeout before it released the mutex.  When invoked with an 
invalid or expired timeout point, the timeout ended the wait immediately with 
`EINVAL` or `ETIMEDOUT`.  The subsequent mutex unlock failure (`EPERM`) had no 
effect because the wait state was already closed.  
`_POSIX_Condition_variables_Wait_support()` saw a return code other than 
`EPERM` and acquired the mutex.  As a consequence, a caller that did not own 
the mutex acquired ownership upon wait return.

Release the mutex in 
`_POSIX_Condition_variables_Enqueue_with_timeout_by_clock_id()` before adding 
the timeout.  If the caller does not own the mutex, the unlock failure unblocks 
the thread with `STATUS_NOT_OWNER` and closes the wait state.  A subsequent 
timeout expiration has no effect on the wait status, and the function returns 
`EPERM` without acquiring the mutex.

In `psxcond01`, add test cases for `pthread_cond_timedwait()` and 
`pthread_cond_clockwait()` with an unowned mutex and expired or invalid 
timeouts.  In `psx10`, lock the mutex before the clockwait calls.

Close #5819.

-- 
View it on GitLab: 
https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1601
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-8iqqzx66o6zma34f5zpnnjbqb-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