Skip to content

Commit

Permalink
[ci skip] Add note in gc.c about ambiguous case
Browse files Browse the repository at this point in the history
  • Loading branch information
peterzhu2118 committed Feb 24, 2023
1 parent 3e09822 commit fa1eb31
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions gc.c
Expand Up @@ -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++;
Expand Down

0 comments on commit fa1eb31

Please sign in to comment.