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

Fix ForkTracker on ruby <= 2.5.3 #40638

Merged
merged 1 commit into from
Nov 18, 2020
Merged

Fix ForkTracker on ruby <= 2.5.3 #40638

merged 1 commit into from
Nov 18, 2020

Conversation

p8
Copy link
Member

@p8 p8 commented Nov 17, 2020

Summary

Making the fork method private by calling private :fork raises a
"no superclass method `fork'" error when calling super in a subclass on
ruby <= 2.5.3. The error doesn't occur on ruby 2.5.4 and higher.
Making the method private by redefining doesn't raise the error.

Other Information

The possible fix on 2.5.4 is ruby/ruby@75aba10

The error can be reproduced with the following script on ruby 2.5.3:

class Cluster
  def start
    fork { puts "forked!" }
  end
end

module CoreExt
  def fork(*)
    super
  end
end

module CoreExtPrivate
  include CoreExt
  private :fork
end

::Object.prepend(CoreExtPrivate)
Cluster.new.start

Fixes #40603

Making the fork method private by calling `private :fork` raises a
"no superclass method `fork'" error when calling super in a subclass on
ruby <= 2.5.3. The error doesn't occur on ruby 2.5.4 and higher.
Making the method private by redefining doesn't raise the error.

The possible fix on 2.5.4 is ruby/ruby@75aba10

The error can be reproduced with the following script on ruby 2.5.3:
```
class Cluster
  def start
    fork { puts "forked!" }
  end
end

module CoreExt
  def fork(*)
    super
  end
end

module CoreExtPrivate
  include CoreExt
  private :fork
end

::Object.prepend(CoreExtPrivate)
Cluster.new.start
```

Fixes #40603
@rafaelfranca rafaelfranca merged commit ff97127 into rails:master Nov 18, 2020
@p8 p8 deleted the fix/fork-tracker-ruby-2.5.3 branch November 18, 2020 18:11
rafaelfranca added a commit that referenced this pull request Nov 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6.1.0.rc1 no superclass method `fork' - fork_tracker.rb
2 participants