Skip to content

Ensure hard reference for frozen strings#1348

Open
headius wants to merge 1 commit intoruby:masterfrom
headius:avoid_frozen_literal_gc
Open

Ensure hard reference for frozen strings#1348
headius wants to merge 1 commit intoruby:masterfrom
headius:avoid_frozen_literal_gc

Conversation

@headius
Copy link
Contributor

@headius headius commented Feb 27, 2026

These frozen strings must be hard referenced until the identity has been tested, or an intervening GC could cause them to get collected and improperly fail the test. The cross-require global now points at the string in question and is cleared after the identity test.

These frozen strings must be hard referenced until the identity
has been tested, or an intervening GC could cause them to get
collected and improperly fail the test. The cross-require global
now points at the string in question and is cleared after the
identity test.
@headius
Copy link
Contributor Author

headius commented Feb 27, 2026

Spurious failure in JRuby tests here was most likely due to unlucky GC timing. This should prevent such failures in the future:

https://github.com/jruby/jruby/actions/runs/22466746658/job/65074368459

@headius
Copy link
Contributor Author

headius commented Feb 27, 2026

Now RuboCop doesn't like the object_id comparison, but that was the original expectation. Changing to equal? would be an equivalent test.

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.

1 participant