diff options
author | Peter Zhu <[email protected]> | 2023-02-24 16:10:54 -0500 |
---|---|---|
committer | Peter Zhu <[email protected]> | 2023-02-24 16:10:54 -0500 |
commit | fa1eb31fcafc8ffbc8bd8557119e9a30905101b2 (patch) | |
tree | ef0306ca519f0df69fd670c0232648fb7a7d6c10 /gc.c | |
parent | 3e098224077e8c43a1d8c2070b26ffdfda422780 (diff) |
[ci skip] Add note in gc.c about ambiguous case
Diffstat (limited to 'gc.c')
-rw-r--r-- | gc.c | 23 |
1 files changed, 18 insertions, 5 deletions
@@ -2495,11 +2495,24 @@ gc_event_hook_body(rb_execution_context_t *ec, rb_objspace_t *objspace, const rb * the currently executing instruction. We should increment the PC * because the source line is calculated with PC-1 in calc_pos. * - * If the previous instruction is not a leaf instruction, then the PC - * was incremented before the instruction was ran (meaning the - * currently executing instruction is actually the previous - * instruction), so we should not increment the PC otherwise we will - * calculate the source line for the next instruction. + * If the previous instruction is not a leaf instruction and the + * current instruction is not a leaf instruction, then the PC was + * incremented before the instruction was ran (meaning the currently + * executing instruction is actually the previous instruction), so we + * should not increment the PC otherwise we will calculate the source + * line for the next instruction. + * + * However, this implementation still has a bug. Consider the + * following situation: + * + * non-leaf + * leaf <- + * + * Where the PC currently points to a leaf instruction. We don't know + * which instruction we really are at since we could be at the non-leaf + * instruction (since it incremented the PC before executing the + * instruction). We could also be at the leaf instruction since the PC + * doesn't get incremented until the instruction finishes. */ if (rb_insns_leaf_p(prev_opcode)) { ec->cfp->pc++; |