Skip to content

Commit

Permalink
Memerror is fatal if VM cannot be unlocked.
Browse files Browse the repository at this point in the history
[Bug #20942]

If we've raised a memerror while the VM is locked, and the tag we're
jumping to has been locked at a different level to the current lock (ie.
we've locked the VM again since the tag we're jumping to) then we should
consider this memerror fatal and exit, since the tag cannot unlock the
VM.

Co-Authored-By: Peter Zhu <peter@peterzhu.ca>
  • Loading branch information
eightbitraptor and peterzhu2118 committed Dec 20, 2024
1 parent 978df25 commit 2f6c694
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4481,7 +4481,8 @@ rb_memerror(void)
VALUE exc = GET_VM()->special_exceptions[ruby_error_nomemory];

if (!exc ||
rb_ec_raised_p(ec, RAISED_NOMEMORY)) {
rb_ec_raised_p(ec, RAISED_NOMEMORY) ||
rb_ec_vm_lock_rec(ec) != ec->tag->lock_rec) {
fprintf(stderr, "[FATAL] failed to allocate memory\n");
exit(EXIT_FAILURE);
}
Expand Down

0 comments on commit 2f6c694

Please sign in to comment.