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

RUBY-3557 Mark SecureRandom as Global #341

Merged

Conversation

zacheryph
Copy link
Contributor

@zacheryph zacheryph commented Nov 14, 2024

SecureRandom needs to be marked global so that it cannot be moved during GC compaction. When this happens the pvt_SecureRandom may reference a different object, or nothing at all causing a segfault.

I am not quite sure how a test would be written for this since it'd have to be run on its own, and it segfaults the process so the suite wouldn't run. This can be reproduced (on master), and shown resolved (on this branch) with the following:

rake compile
bundle console

irb> GC.verify_compaction_references(expand_heap: true, toward: :empty);
irb> BSON::ObjectId.new

SecureRandom needs to be marked global so that it
does not possibly get moved during GC compaction.
@comandeo-mongo comandeo-mongo self-requested a review November 15, 2024 08:27
Copy link
Contributor

@comandeo-mongo comandeo-mongo left a comment

Choose a reason for hiding this comment

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

@zacheryph This is fantastic, thank you very much for your contribution!

@comandeo-mongo comandeo-mongo merged commit edcaa40 into mongodb:master Nov 15, 2024
43 checks passed
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