ruby-changes:69007
From: Maxime <ko1@a...>
Date: Thu, 21 Oct 2021 08:19:40 +0900 (JST)
Subject: [ruby-changes:69007] 99341d4a18 (master): Fix issue in yjit_free_block causing segfault
https://git.ruby-lang.org/ruby.git/commit/?id=99341d4a18 From 99341d4a18805db6426c833da0a1d7e1e1f05bd4 Mon Sep 17 00:00:00 2001 From: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@s...> Date: Tue, 8 Jun 2021 14:15:02 -0400 Subject: Fix issue in yjit_free_block causing segfault This addresses issue #55 --- yjit_core.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/yjit_core.c b/yjit_core.c index eae43c38f7..088b0593d1 100644 --- a/yjit_core.c +++ b/yjit_core.c @@ -816,6 +816,19 @@ yjit_free_block(block_t *block) https://github.com/ruby/ruby/blob/trunk/yjit_core.c#L816 yjit_unlink_method_lookup_dependency(block); yjit_block_assumptions_free(block); + // Remove this block from the predecessor's targets + rb_darray_for(block->incoming, incoming_idx) { + // Branch from the predecessor to us + branch_t* pred_branch = rb_darray_get(block->incoming, incoming_idx); + + // If this is us, nullify the target block + for (size_t succ_idx = 0; succ_idx < 2; succ_idx++) { + if (pred_branch->blocks[succ_idx] == block) { + pred_branch->blocks[succ_idx] = NULL; + } + } + } + // For each outgoing branch rb_darray_for(block->outgoing, branch_idx) { branch_t* out_branch = rb_darray_get(block->outgoing, branch_idx); -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/