Add support for Python 3.14 tail call interpreter in native stack trace analysis#836
Conversation
|
@copilot you need to change the cython pyx file to detect the eval functions that have LLVM names now. That is the most important part. |
I've already updated the Cython
Both functions now recognize symbols that start with |
|
@copilot You need a NEWS entry in news for towncrier |
|
@copilot We also need a new workflow that checks with Python from UV (3.14) that has the tail call activated. We can use the uv GitHub action: We just need 3.14. Check other workflows such as the coverage one or the valgrind one to know more or less how that must be done |
Added GitHub Actions workflow in commit 190f326. The workflow is in |
|
@copilot This is not running with Python from Also run all tests not just that one |
Updated in commit d8d8ee4:
|
|
@copilot you need to create a venv first: Ensure to use 3.14 there |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #836 +/- ##
==========================================
- Coverage 92.46% 92.39% -0.07%
==========================================
Files 99 99
Lines 11840 11842 +2
Branches 425 426 +1
==========================================
- Hits 10948 10942 -6
- Misses 892 900 +8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
1222d0c to
a82ef86
Compare
Implement support for Python 3.14's tail call interpreter in Memray. The changes enable Memray to correctly identify Python frame boundaries when native stack traces contain LLVM-generated tail call functions. Signed-off-by: Pablo Galindo Salgado <pablogsal@gmail.com>
a82ef86 to
c6b56cb
Compare
Plan to fix Python 3.14 tail call interpreter support
frame_tools.pythat identifies Python frame boundaries_is_cpython_internal_symbolfunction to recognize_TAIL_CALL_*.llvm.*patternsuv runand run all testsuv venvstep to create virtual environmentSummary
Successfully implemented support for Python 3.14's tail call interpreter in Memray. The changes enable Memray to correctly identify Python frame boundaries when native stack traces contain LLVM-generated tail call functions.
Changes Made
1. Pure Python Code (
src/memray/reporters/frame_tools.py)_TAIL_CALL_*.llvm.*symbols2. Cython Code (
src/memray/_memray.pyx)hybrid_stack_trace()to recognize tail call patterns in native stack correlationget_symbolic_support()to detect tail call patterns for symbolic support3. Tests (
tests/unit/test_frame_tools.py)_TAIL_CALL_INSTRUMENTED_CALL.llvm.*patterns_TAIL_CALL_POP_TOP.llvm.*patternsis_frame_interesting()to ensure proper filtering4. NEWS Entry (
news/822.bugfix)5. CI/CD Workflow (
.github/workflows/test_uv_python.yml)astral-sh/setup-uv@v6action to install Python 3.14uv venv --python 3.14uv run pytestto run all tests with UV's Python environmentPattern Detection Logic
A symbol is recognized as a Python frame boundary if:
_PyEval_EvalFrameDefaultorPyEval_EvalFrameEx(traditional), OR_TAIL_CALL_AND contains.llvm.(Python 3.14 tail call)Backward Compatibility
✓ Python 3.8-3.13: Traditional
_PyEval_EvalFrameDefaultdetection continues to work✓ Python 3.14 without tail call: Traditional detection continues to work
✓ Python 3.14 with tail call: New LLVM pattern detection is activated
✓ All patterns can coexist in mixed environments
Code Statistics
frame_tools.py(core logic)_memray.pyx(including comments)test_frame_tools.py(test coverage)The implementation is minimal, surgical, and maintains full backward compatibility.
Original prompt
Fixes #822
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.