pthread: implement rwlocks#505
Conversation
There was a problem hiding this comment.
Code Review
This pull request implements POSIX read-write locks (pthread_rwlock_t and pthread_rwlockattr_t) and adds the pthread_testcancel cancellation point. The review feedback highlights several critical issues and improvement opportunities: standard POSIX functions should return positive error codes instead of negative ones, and local variable shadowing should be resolved in pthread_rwlock_lazy_init. Additionally, missing NULL checks in pthread_rwlockattr_setpshared, pthread_rwlock_destroy, and timespec_is_valid should be added to prevent potential crashes. The initialized field in pthread_rwlock_t should be declared as volatile int to ensure thread safety, and the return type of timespec_is_valid should be changed from time_t to int.
3adc0f2 to
b8f7aa0
Compare
85344ca to
2ca5da8
Compare
b8f7aa0 to
972b2ee
Compare
972b2ee to
668d57b
Compare
| #define PTHREAD_SCOPE_SYSTEM 1 | ||
|
|
||
| #define PTHREAD_MUTEX_INITIALIZER { 0, 0 } | ||
| #define PTHREAD_RWLOCK_INITIALIZER { 0 } |
There was a problem hiding this comment.
[clang-format-pr] reported by reviewdog 🐶
suggested fix
| #define PTHREAD_RWLOCK_INITIALIZER { 0 } | |
| #define PTHREAD_RWLOCK_INITIALIZER \ | |
| { \ | |
| 0 \ | |
| } |
668d57b to
905aea8
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request implements POSIX read-write locks (pthread_rwlock_t and pthread_rwlockattr_t) and adds support for thread cancellation via pthread_testcancel. The review feedback highlights two critical issues: a potential segmentation fault in timespec_is_valid due to a missing NULL check on the time pointer, and a concurrency bug in the cancellation logic where cleanup handlers and key data lists can be executed or freed twice, leading to double-free or use-after-free vulnerabilities.
905aea8 to
3b81e22
Compare
TASK: RTOS-1389
TASK: RTOS-1389
TASK: RTOS-1389
3b81e22 to
3a3e9ee
Compare
Unit Test Results11 307 tests 10 600 ✅ 52m 55s ⏱️ Results for commit 3a3e9ee. |
TASK: RTOS-1389
Description
Motivation and Context
Types of changes
How Has This Been Tested?
Checklist:
Special treatment