Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bootsnap breaks Zeitwerk on Ruby 2.5.x #244

Closed
casperisfine opened this issue Mar 8, 2019 · 6 comments
Closed

Bootsnap breaks Zeitwerk on Ruby 2.5.x #244

casperisfine opened this issue Mar 8, 2019 · 6 comments

Comments

@casperisfine
Copy link
Contributor

There's a bug on Ruby 2.5, when code is loaded a ISeq TracePoint callbacks are not fired:

iseq = RubyVM::InstructionSequence.compile(<<-RUBY)
  class A
    class B
    end
  end
RUBY

iseq_bin = iseq.to_binary
TracePoint.new(:end){|tp|
  p tp.lineno
}.enable{
  RubyVM::InstructionSequence.load_from_binary(iseq_bin).eval
}

TracePoint.new(:class){|tp|
  p "class #{tp.lineno}"
}.enable{
  RubyVM::InstructionSequence.load_from_binary(iseq_bin).eval
}

This snippet prints nothing on MRI 2.5, but works as expected on 2.6.

The issue with this is that Zeitwerk, that's the default autoloader on Rails 6 rely on TracePoint to work properly. Since Rails also include bootsnap as default, 2.5 users trying to use Rails 6 might encounter very weird load issues.

I'm not quite sure what can be done, but It would probably be best to figure something out before Rails 6 is released.

@burke @fxn @rafaelfranca thoughts on this?

Rails load bootsnap/setup: https://github.com/Shopify/bootsnap/blob/master/lib/bootsnap/setup.rb

I suppose we could check the Ruby version and set compile_cache_iseq: false for MRI 2.5 ?

The perf hit is quite significant, but if it can save headaches for users, it might be best.

@rafaelfranca
Copy link
Member

This bug is fixed already in Ruby, it is just not released. They are planning a release next week. Related with rails/rails#35475.

I think we can just wait the new Ruby release. It will happen before Rails 6 final is released.

@casperisfine
Copy link
Contributor Author

Oh great. Well closing this then.

@fxn
Copy link

fxn commented Apr 1, 2019

Ruby 2.5.5 still has this problem.

@casperisfine
Copy link
Contributor Author

Yeah we discovered this the hard way. The TracePoint patch was supposed to be part of 2.5.5, but the release was borked and that fix wasn't properly included...

@rafaelfranca rafaelfranca reopened this Apr 1, 2019
@fxn
Copy link

fxn commented Apr 25, 2019

For the archives: after #257 the default setup has this cache disabled.

The issue is probably worth being open still, however, because it affects people enabling the cache by hand.

@casperisfine
Copy link
Contributor Author

Seems like the fix was never properly backported to 2.5, however bootsnap no longer enable ISeq caching by default on 2.5.x, and I added a warning if users enable it manually: eab8d8d

I think we can close this now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants