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

Register global variables to the GC #91

Merged
merged 1 commit into from
Feb 15, 2021

Conversation

casperisfine
Copy link

Context

Ruby 2.7 introduced GC compaction. This means that objects can me moved from on GC slot to another. Since then C extensions must declare all the VALUE they keep in global variables with rb_global_variable. This allow the GC to update the references held by C extensions.

Ruby 3.0 added GC.verify_compaction_references which makes it easier to test that all references are properly declared. All objects are moved to new heap pages, so after than any attempt to use undeclared global variable is extremly likely to segfault.

This PR

I simply declare all the global variables and add Ruby 3.0 to the test matrix.

Copy link
Owner

@yosiat yosiat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the amazing PR!

I planned to do it but didn't about the verify_compaction_references method.

@yosiat yosiat merged commit 36f4575 into yosiat:master Feb 15, 2021
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.

None yet

3 participants