https://github.com/python/cpython/commit/4ceb077c5cea30fef734f4c4e92c18d978be6c38
commit: 4ceb077c5cea30fef734f4c4e92c18d978be6c38
branch: main
author: Pablo Galindo Salgado <[email protected]>
committer: pablogsal <[email protected]>
date: 2025-11-15T02:23:54Z
summary:
gh-141579: Fix perf_jit backend in sys.activate_stack_trampoline() (#141580)
files:
A
Misc/NEWS.d/next/Core_and_Builtins/2025-11-15-01-21-00.gh-issue-141579.aB7cD9.rst
M Lib/test/test_perf_profiler.py
M Python/sysmodule.c
diff --git a/Lib/test/test_perf_profiler.py b/Lib/test/test_perf_profiler.py
index 13424991639215..e6852c93e69830 100644
--- a/Lib/test/test_perf_profiler.py
+++ b/Lib/test/test_perf_profiler.py
@@ -238,6 +238,24 @@ def test_sys_api_get_status(self):
"""
assert_python_ok("-c", code, PYTHON_JIT="0")
+ def test_sys_api_perf_jit_backend(self):
+ code = """if 1:
+ import sys
+ sys.activate_stack_trampoline("perf_jit")
+ assert sys.is_stack_trampoline_active() is True
+ sys.deactivate_stack_trampoline()
+ assert sys.is_stack_trampoline_active() is False
+ """
+ assert_python_ok("-c", code, PYTHON_JIT="0")
+
+ def test_sys_api_with_existing_perf_jit_trampoline(self):
+ code = """if 1:
+ import sys
+ sys.activate_stack_trampoline("perf_jit")
+ sys.activate_stack_trampoline("perf_jit")
+ """
+ assert_python_ok("-c", code, PYTHON_JIT="0")
+
def is_unwinding_reliable_with_frame_pointers():
cflags = sysconfig.get_config_var("PY_CORE_CFLAGS")
diff --git
a/Misc/NEWS.d/next/Core_and_Builtins/2025-11-15-01-21-00.gh-issue-141579.aB7cD9.rst
b/Misc/NEWS.d/next/Core_and_Builtins/2025-11-15-01-21-00.gh-issue-141579.aB7cD9.rst
new file mode 100644
index 00000000000000..8ab9979c39917b
--- /dev/null
+++
b/Misc/NEWS.d/next/Core_and_Builtins/2025-11-15-01-21-00.gh-issue-141579.aB7cD9.rst
@@ -0,0 +1,2 @@
+Fix :func:`sys.activate_stack_trampoline` to properly support the
+``perf_jit`` backend. Patch by Pablo Galindo.
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index a611844f76e090..b4b441bf4d9519 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -2380,14 +2380,14 @@ sys_activate_stack_trampoline_impl(PyObject *module,
const char *backend)
return NULL;
}
}
- else if (strcmp(backend, "perf_jit") == 0) {
- _PyPerf_Callbacks cur_cb;
- _PyPerfTrampoline_GetCallbacks(&cur_cb);
- if (cur_cb.write_state != _Py_perfmap_jit_callbacks.write_state) {
- if (_PyPerfTrampoline_SetCallbacks(&_Py_perfmap_jit_callbacks)
< 0 ) {
- PyErr_SetString(PyExc_ValueError, "can't activate perf jit
trampoline");
- return NULL;
- }
+ }
+ else if (strcmp(backend, "perf_jit") == 0) {
+ _PyPerf_Callbacks cur_cb;
+ _PyPerfTrampoline_GetCallbacks(&cur_cb);
+ if (cur_cb.write_state != _Py_perfmap_jit_callbacks.write_state) {
+ if (_PyPerfTrampoline_SetCallbacks(&_Py_perfmap_jit_callbacks) < 0
) {
+ PyErr_SetString(PyExc_ValueError, "can't activate perf jit
trampoline");
+ return NULL;
}
}
}
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]