Skip to content

Fix Ractor compatibility regression, add tests - #127

Open
hmcguire-shopify wants to merge 2 commits into
ruby:masterfrom
Shopify:hm-knszqllqxxrppkqp
Open

Fix Ractor compatibility regression, add tests#127
hmcguire-shopify wants to merge 2 commits into
ruby:masterfrom
Shopify:hm-knszqllqxxrppkqp

Conversation

@hmcguire-shopify

Copy link
Copy Markdown

The recent change to use BasicObject.instance_method(:equal?) broke
the ability to share frozen ERB templates across Ractors because
UnboundMethod isn't shareable.

Freezing the UnboundMethod may fix the issue (dependong on Ruby
version), but replacing the constant with an inline call to the
singleton_class is simpler (and still avoids calling equal? on
@init).

There have previously been many contributions to make ERB Ractor safe,
but no tests added to ensure it continues to be Ractor safe, so this
commit also adds some regression tests.


Simplify Scanner's Ractor safety code

Ractor.make_shareable isn't needed if everything is plain freezed

The recent change to use `BasicObject.instance_method(:equal?)` broke
the ability to share frozen ERB templates across Ractors because
`UnboundMethod` isn't shareable.

Freezing the `UnboundMethod` _may_ fix the issue (dependong on Ruby
version), but replacing the constant with an inline call to the
`singleton_class` is simpler (and still avoids calling `equal?` on
`@init`).

There have previously been many contributions to make ERB Ractor safe,
but no tests added to ensure it continues to be Ractor safe, so this
commit also adds some regression tests.
Ractor.make_shareable isn't needed if everything is plain `freeze`d
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

Successfully merging this pull request may close these issues.

2 participants