Closed
Description
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
Labels
No labels