RTEMS | pthread_cancel behavior inconsistency with POSIX (#5181)
yang zhang (@yang.zhang)
gitlab at rtems.org
Mon Jan 6 08:42:51 UTC 2025
yang zhang created an issue: https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5181
## Summary
I use a sample code in man pthread_cancel to test pthread_cancle it rtems, but it can't work.
## Steps to reproduce
1. I reusing posix testcases -- psxcancel
2. Modify in by sample code in man pthread_cancel
3. Check the output log, it should be as below:
thread_func(): started; cancellation disabled
main(): sending cancellation request
thread_func(): about to enable cancellation
main(): thread was canceled
But actually, it's as below:
thread_func(): started; cancellation disabled
main(): sending cancellation request
thread_func(): about to enable cancellation
//sleep 100s
thread_func(): not canceled!
main(): thread wasn't canceled (shouldn't happen!)
## Information
As man pthread_cancel say
"If a thread has disabled cancellation, then a cancellation request remains queued until the thread enables cancellation."
" Deferred cancelability means that cancellation will be delayed until the thread next calls a function that is a cancellation point. "
" Cancellation points
POSIX.1 specifies that certain functions must, and certain
other functions may, be cancellation points. If a thread is
cancelable, its cancelability type is deferred, and a cancella‐
tion request is pending for the thread, then the thread is can‐
celed when it calls a function that is a cancellation point."
//the test case for rtems
[pthread_cancel.diff](/uploads/3802221a7da3d2e8b85d35e8477158dc/pthread_cancel.diff)
//the sample code in man pthread_cancel
[test_cancel_posix.c](/uploads/96a574a3d50ddd4d06e4b809ef3a4237/test_cancel_posix.c)
--
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5181
You're receiving this email because of your account on gitlab.rtems.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/bugs/attachments/20250106/f17850af/attachment.htm>
More information about the bugs
mailing list