From 81ad3d38460f73516407d75a628ff5de9044f288 Mon Sep 17 00:00:00 2001 From: Levi Neely <141506390+lneely@users.noreply.github.com> Date: Tue, 3 Mar 2026 12:18:31 +0100 Subject: [PATCH] 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 --- pclsync/ptimer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pclsync/ptimer.c b/pclsync/ptimer.c index 2b0f703..6067d5f 100644 --- a/pclsync/ptimer.c +++ b/pclsync/ptimer.c @@ -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();