Bug report
Bug description:
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.
import sys
from concurrent import interpreters
interpreters.create().exec("import sys; sys.activate_stack_trampoline('perf_jit')")
def hot(n):
t = 0
for i in range(n):
t += i & 3
return t
for _ in range(50):
hot(100000)
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.
Found while working on #157246
CPython versions tested on:
CPython main branch, 3.16
Operating systems tested on:
Linux
Linked PRs
Bug report
Bug description:
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 activateperf_jitwhile 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.
Found while working on #157246
CPython versions tested on:
CPython main branch, 3.16
Operating systems tested on:
Linux
Linked PRs