mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
mutex: Raise a ThreadError when detecting a fiber deadlock (#6680)
[Bug #19105] If no fiber scheduler is registered and the fiber that owns the lock and the one that try to acquire it both belong to the same thread, we're in a deadlock case. Co-authored-by: Jean Boussier <byroot@ruby-lang.org>
This commit is contained in:
parent
cdb3ec3af8
commit
eacedcfe44
Notes:
git
2022-11-08 11:43:48 +00:00
Merged-By: ioquatix <samuel@codeotaku.com>
2 changed files with 25 additions and 1 deletions
|
@ -327,6 +327,10 @@ do_mutex_lock(VALUE self, int interruptible_p)
|
|||
}
|
||||
}
|
||||
else {
|
||||
if (!th->vm->thread_ignore_deadlock && rb_fiber_threadptr(mutex->fiber) == th) {
|
||||
rb_raise(rb_eThreadError, "deadlock; lock already owned by another fiber belonging to the same thread");
|
||||
}
|
||||
|
||||
enum rb_thread_status prev_status = th->status;
|
||||
rb_hrtime_t *timeout = 0;
|
||||
rb_hrtime_t rel = rb_msec2hrtime(100);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue