Skip to content

Commit

Permalink
Free default_rand_key after freeing Ractors
Browse files Browse the repository at this point in the history
Ractor's free iterates through its TLS keys so we need to keep this
memory available until after Ractors are freed.

Minimal reproduction:

    RUBY_FREE_AT_EXIT=1 ./miniruby -e rand
  • Loading branch information
jhawthorn committed Dec 23, 2023
1 parent 697a096 commit 339978e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion vm.c
Expand Up @@ -2994,7 +2994,6 @@ ruby_vm_destruct(rb_vm_t *vm)
rb_thread_t *th = vm->ractor.main_thread;
VALUE *stack = th->ec->vm_stack;
if (rb_free_at_exit) {
rb_free_default_rand_key();
rb_free_encoded_insn_data();
rb_free_global_enc_table();
rb_free_loaded_builtin_table();
Expand Down Expand Up @@ -3056,6 +3055,7 @@ ruby_vm_destruct(rb_vm_t *vm)
if (rb_free_at_exit) {
rb_objspace_free_objects(objspace);
rb_free_generic_iv_tbl_();
rb_free_default_rand_key();
if (th) {
xfree(stack);
ruby_mimfree(th);
Expand Down

0 comments on commit 339978e

Please sign in to comment.