diff options
author | Samuel Williams <samuel.williams@oriontransfer.co.nz> | 2023-03-07 20:23:00 +1300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-07 20:23:00 +1300 |
commit | 2c4b2053ca1884f058982fd46f2576bd887920b6 (patch) | |
tree | 7cd7c73225bd1b7345bd5497e2a392b852cbc9fb /thread.c | |
parent | 011c08b643757b2369f28fcae190ad1e98623789 (diff) |
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>.
Notes
Notes:
Merged-By: ioquatix <samuel@codeotaku.com>
Diffstat (limited to 'thread.c')
-rw-r--r-- | thread.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -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); |