diff options
author | Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com> | 2021-06-08 14:15:02 -0400 |
---|---|---|
committer | Alan Wu <XrXr@users.noreply.github.com> | 2021-10-20 18:19:35 -0400 |
commit | 99341d4a18805db6426c833da0a1d7e1e1f05bd4 (patch) | |
tree | 95a858ffa0e6386cd22da74afba0312e999edb83 /yjit_core.c | |
parent | 67c2cdc59a5fc8a82804c72a30a2d23ba36f2366 (diff) |
Fix issue in yjit_free_block causing segfault
This addresses issue #55
Diffstat (limited to 'yjit_core.c')
-rw-r--r-- | yjit_core.c | 13 |
1 files changed, 13 insertions, 0 deletions
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) 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); |