Skip to content

Commit

Permalink
RUBY-3557 Mark SecureRandom as Global (#341)
Browse files Browse the repository at this point in the history
SecureRandom needs to be marked global so that it
does not possibly get moved during GC compaction.
  • Loading branch information
zacheryph authored Nov 15, 2024
1 parent e1f5d8f commit edcaa40
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ext/bson/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ VALUE pvt_load_secure_random(VALUE _arg) {
pvt_SecureRandom = rb_const_get(rb_cObject, rb_intern("SecureRandom"));
pvt_has_random_number = rb_respond_to(pvt_SecureRandom, rb_intern("random_number"));

// mark SecureRandom so it does not get moved
rb_global_variable(&pvt_SecureRandom);

return Qnil;
}

Expand Down

0 comments on commit edcaa40

Please sign in to comment.