A fiber issue with `autoload`: `fiber called across stack rewinding barrier (FiberError)`

453 views Asked by At

We are using fiber with eventmachine (em-synchrony) in our production env for quite a long time, and it works very well. We use the outdated ruby 1.9.3 and ActiveRecord 3.x for over 2 years. We are migrating those two big parts to the latest versions.

When trying to upgrade ruby to the latest, we got an exception fiber called across stack rewinding barrier (FiberError) in 2.0+, but not in 1.9.3. Can you guys help us to figure out this problem?

Minimal sample:

test.rb

autoload :User, './user.rb'

f = Fiber.new do
  p User
end
f.resume
f.resume

user.rb

class User
end

Fiber.yield # This line is important

run

$ rvm 1.9.3,2.0,2.1 do sh -c 'echo ==== $RUBY_VERSION; ruby test.rb'
==== ruby-1.9.3-p551
User
==== ruby-2.0.0-p598
user.rb:4:in `yield': fiber called across stack rewinding barrier (FiberError)
    from user.rb:4:in `<top (required)>'
    from test.rb:4:in `block in <main>'
==== ruby-2.1.5
user.rb:4:in `yield': fiber called across stack rewinding barrier (FiberError)
    from user.rb:4:in `<top (required)>'
    from test.rb:4:in `block in <main>'

More sample codes are in this repo:

https://github.com/qqshfox/test_fiber

Any help would be appreciated!

0

There are 0 answers