Skip to content

RUBY-3557 Mark SecureRandom as Global#341

Merged
comandeo-mongo merged 1 commit into
mongodb:masterfrom
zacheryph:fix/mark-securerandom-as-global
Nov 15, 2024
Merged

RUBY-3557 Mark SecureRandom as Global#341
comandeo-mongo merged 1 commit into
mongodb:masterfrom
zacheryph:fix/mark-securerandom-as-global

Conversation

@zacheryph

@zacheryph zacheryph commented Nov 14, 2024

Copy link
Copy Markdown
Contributor

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

@comandeo-mongo comandeo-mongo left a comment

Copy link
Copy Markdown
Contributor

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
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