Project

General

Profile

Actions

Bug #19105

closed

mutex: Raise a ThreadError when detecting a fiber deadlock

Added by byroot (Jean Boussier) about 2 years ago. Updated about 2 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:110626]

Description

The following code can lead to a deadlock but not raise any error:

mutex = Mutex.new
mutex.synchronize do
  error = assert_raise ThreadError do
    Fiber.new do
      mutex.lock
    end.resume
  end
end

If no fiber scheduler is registered, and both the fiber that currently own the lock and the one trying to acquire it belongs to the same thread, then this deadlock situation cannot possibly resolve (aside from a signal interrupt maybe).

Discussed in https://bugs.ruby-lang.org/issues/17827#note-10
Pull request: https://github.com/ruby/ruby/pull/6680


Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #17827: Monitor is not fiber safeClosedEregon (Benoit Daloze)Actions
Actions #1

Updated by byroot (Jean Boussier) about 2 years ago

  • Related to Bug #17827: Monitor is not fiber safe added
Actions #2

Updated by Anonymous about 2 years ago

  • Status changed from Open to Closed

Applied in changeset git|eacedcfe44a0ae22bf54ddb7df193c48d4c857c6.


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

Updated by nagachika (Tomoyuki Chikanaga) about 2 years ago

  • Backport changed from 2.7: DONTNEED, 3.0: REQUIRED, 3.1: REQUIRED to 2.7: DONTNEED, 3.0: REQUIRED, 3.1: DONE

ruby_3_1 61818395312c6e765dc8e7be8bf32cd2c82fec39 merged revision(s) eacedcfe44a0ae22bf54ddb7df193c48d4c857c6.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0