Skip to content

Commit 2f6c694

Browse files
Memerror is fatal if VM cannot be unlocked.
[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 <[email protected]>
1 parent 978df25 commit 2f6c694

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

gc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4481,7 +4481,8 @@ rb_memerror(void)
44814481
VALUE exc = GET_VM()->special_exceptions[ruby_error_nomemory];
44824482

44834483
if (!exc ||
4484-
rb_ec_raised_p(ec, RAISED_NOMEMORY)) {
4484+
rb_ec_raised_p(ec, RAISED_NOMEMORY) ||
4485+
rb_ec_vm_lock_rec(ec) != ec->tag->lock_rec) {
44854486
fprintf(stderr, "[FATAL] failed to allocate memory\n");
44864487
exit(EXIT_FAILURE);
44874488
}

0 commit comments

Comments
 (0)