aboutsummaryrefslogtreecommitdiffstats
path: root/thread.c
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2023-03-07 20:23:00 +1300
committerGitHub <noreply@github.com>2023-03-07 20:23:00 +1300
commit2c4b2053ca1884f058982fd46f2576bd887920b6 (patch)
tree7cd7c73225bd1b7345bd5497e2a392b852cbc9fb /thread.c
parent011c08b643757b2369f28fcae190ad1e98623789 (diff)
downloadruby-2c4b2053ca1884f058982fd46f2576bd887920b6.tar.gz
Correctly clean up `keeping_mutexes` before resuming any other threads. (#7460)
It's possible (but very rare) to have a race condition between setting `mutex->fiber = NULL` and `thread_mutex_remove(th, mutex)` which results in the following bug: ``` [BUG] invalid keeping_mutexes: Attempt to unlock a mutex which is not locked ``` Fixes <https://bugs.ruby-lang.org/issues/19480>.
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/thread.c b/thread.c
index cf8b9ed87b..4e662f6b66 100644
--- a/thread.c
+++ b/thread.c
@@ -428,7 +428,7 @@ rb_threadptr_unlock_all_locking_mutexes(rb_thread_t *th)
rb_mutex_t *mutex = th->keeping_mutexes;
th->keeping_mutexes = mutex->next_mutex;
- /* rb_warn("mutex #<%p> remains to be locked by terminated thread", (void *)mutexes); */
+ // rb_warn("mutex #<%p> was not unlocked by thread #<%p>", (void *)mutex, (void*)th);
const char *error_message = rb_mutex_unlock_th(mutex, th, mutex->fiber);
if (error_message) rb_bug("invalid keeping_mutexes: %s", error_message);