This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ammar2
Recipients Mark.Shannon, ammar2, nedbat, pablogsal
Date 2020-08-31.03:44:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1598845487.71.0.78228751183.issue41670@roundup.psfhosted.org>
In-reply-to
Content
So I think this is a weird edge case with a set of opcode predictions (GET_ITER -> FOR_ITER -> POP_BLOCK) going outside of a line boundary.

The disassembly of the reproducer above is:

  4           0 SETUP_FINALLY           16 (to 18)

  5           2 LOAD_CONST               1 (())
              4 GET_ITER
        >>    6 FOR_ITER                 4 (to 12)
              8 STORE_FAST               0 (i)
             10 JUMP_ABSOLUTE            6

  6     >>   12 POP_BLOCK
             14 LOAD_CONST               2 (1)
             16 RETURN_VALUE

When computed gotos are disabled and there is a tracing function, instructions 0, 2, 4, 14 and 16 hit the `fast_next_opcode` label and have a chance to be traced as line hits. Note that `maybe_call_line_trace` will only cause a line hit if the instruction that starts a line (POP_BLOCK in this case) is being executed.

When computed gotos are enabled, DISPATCH is a no-op and there is a special case for when tracing is enabled that causes every opcode to go through `fast_next_opcode`: https://github.com/python/cpython/blob/c3a651ad2544d7d1be389b63e9a4a58a92a31623/Python/ceval.c#L1054-L1059

When computed gotos are not enabled, there is no similar check for PREDICT (and might be too costly to add) causing this issue: https://github.com/python/cpython/blob/c3a651ad2544d7d1be389b63e9a4a58a92a31623/Python/ceval.c#L1131-L1141
History
Date User Action Args
2020-08-31 03:44:47ammar2setrecipients: + ammar2, nedbat, Mark.Shannon, pablogsal
2020-08-31 03:44:47ammar2setmessageid: <1598845487.71.0.78228751183.issue41670@roundup.psfhosted.org>
2020-08-31 03:44:47ammar2linkissue41670 messages
2020-08-31 03:44:47ammar2create