Fix data race on excepions in ptimer_do_notify_exception (#301)

excepions is read without holding timer_ex_mutex, but
ptimer_exception_handler() modifies it under the mutex.

Move the read inside the critical section to prevent the race.

Fixes GH #227

Co-authored-by: Levi Neely <lkn@darkstar.example.net>
This commit is contained in:
Levi Neely 2026-03-03 12:18:31 +01:00 committed by GitHub
parent b902d47706
commit 81ad3d3846
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -266,9 +266,9 @@ void ptimer_sleep_handler(psync_exception_callback func) {
void ptimer_do_notify_exception() {
struct exception_list *e;
pthread_t threadid;
e = excepions;
threadid = pthread_self();
pthread_mutex_lock(&timer_ex_mutex);
e = excepions;
while (e) {
if (!pthread_equal(threadid, e->threadid))
e->func();