Skip to content

FiberError: dead fiber called (when non-main threads are killed) #2778

Closed
@e2

Description

@e2

Actual code that likely caused #2773

On jruby-head, the following either throws a "FiberError (dead fiber error)" exception, or never runs the second fiber:

class Task
  def resume
    fiber = Fiber.new { fail NotImplementedError }
    fiber.resume
  end
end

begin
  STDERR.print "resuming... "
  Task.new.resume
rescue NotImplementedError
  STDERR.puts "OK"
end

extra_threads = Thread.list.reject { |th| th == Thread.main }
extra_threads.map(&:kill) # NOTE: extra thread only on JRuby (fiber thread)

begin
  STDERR.print "resuming... "
  Task.new.resume
rescue NotImplementedError
  STDERR.puts "OK"
end

Expected (e.g. on MRI):

$ ruby fiber.rb
resuming... OK
resuming... OK

Actual (on jruby-head):

$ ruby fiber.rb
resuming... OK
resuming... 

The problem: Fibers on JRuby are implemented with threads, but these fiber-related threads shouldn't be exposed through Thread.list (or Thread.main or Thread.current).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions