cases_generator inserts code to save the stack pointer in the incorrect location when statements containing escaping calls are next to preprocessor directives #126211
Labels
type-bug
An unexpected behavior, bug, or error
Bug report
Bug description:
The cases generator will insert code to save the stack pointer at the incorrect location if the statement containing an escaping call is next to a preprocessor directive. For example, running the cases generator on the following code:
will produce
Notice that
_PyFrame_SetStackPointer(frame, stack_pointer);
is placed before the#ifdef Py_GIL_DISABLED
, rather than after it.I think this is caused by the way that the we determine the beginning of the statement that includes the escaping call. We search backwards from an escaping call to find the beginning of statement, stopping when we encounter one of a handful of tokens:
cpython/Tools/cases_generator/analyzer.py
Lines 638 to 643 in 951cb2c
The set of terminal tokens does not include
CMACRO
. When we encounter such a token we'll treat it as part of the statement containing the escaping call.CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
The text was updated successfully, but these errors were encountered: