sys.activate_stack_trampoline() refuses to run while the JIT is active, but it only checks the current interpreter, and the perf state is process-wide. A subinterpreter can activate perf_jit while the main interpreter keeps its JIT.
With PYTHON_JIT=1 ./python buggy_stuff.py on a --enable-experimental-jit build, the resulting /tmp/jit-.dump holds the JIT's executors (records named py::jit:executor), and every one of them is tagged with the unwind information of the 8-byte perf trampoline. Executor frames look different, so perf produces wrong stacks for samples inside JIT code.
Activity
gh-157247: Block perf trampoline activation when the main interpreter…
pythongh-157247: Block perf trampoline activation when the main inter…
pythongh-157247: Block perf trampoline activation when the main inter…
[3.15] gh-157247: Block perf trampoline activation when the main inte…