Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YJIT: Undo add_block_version() in OOM code path #5226

Merged
merged 1 commit into from
Dec 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion yjit_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,7 @@ limit_block_versions(blockid_t blockid, const ctx_t *ctx)
}

static void yjit_free_block(block_t *block);
static void block_array_remove(rb_yjit_block_array_t block_array, block_t *block);

// Immediately compile a series of block versions at a starting point and
// return the starting block.
Expand Down Expand Up @@ -810,7 +811,14 @@ gen_block_version(blockid_t blockid, const ctx_t *start_ctx, rb_execution_contex
else {
// The batch failed. Free everything in the batch
for (int block_idx = 0; block_idx < compiled_count; block_idx++) {
yjit_free_block(batch[block_idx]);
block_t *const to_free = batch[block_idx];

// Undo add_block_version()
rb_yjit_block_array_t versions = yjit_get_version_array(to_free->blockid.iseq, to_free->blockid.idx);
block_array_remove(versions, to_free);

// Deallocate
yjit_free_block(to_free);
}

#if YJIT_STATS
Expand Down