test_c_stack_unwind fails on Linux LoongArch builds
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Bug report
Bug description:
On the Linux LoongArch64 platform, the test_c_stack_unwind test fails because CPython's manually implemented frame-pointer unwinding mechanism fails to recognize the LoongArch stack frame layout (as it relies on the default FRAME_POINTER_NEXT_OFFSET and FRAME_POINTER_RETURN_OFFSET). This issue affects builds using both GCC and Clang.
In the LoongArch architecture, the frame pointer points to the caller's stack pointer; the previous frame pointer is stored at fp[-2], and the return address is stored at fp[-1].
Additionally, for CPython builds compiled with Clang, unexpected failures occur in test sections involving the GNU backtrace() function. By default, Clang/LoongArch generates .debug_frame sections but does not generate the .eh_frame unwinding tables required for runtime unwinding of CPython's C objects. Consequently, glibc's backtrace() returns only a single stack frame and cannot unwind through Python stack frames.
Reproducer
GCC build:
../cpython/configure --with-pydebug CC=gcc
make -j8
PYTHON_JIT=0 ./python -m test -v test_c_stack_unwind
clang build:
../cpython/configure --with-pydebug CC=clang
make -j8
PYTHON_JIT=0 ./python -m test -v test_c_stack_unwind
Environment
- CPython main
- Linux LoongArch64
- GCC version: 15.3.0
- Clang 20.1.8
- glibc 2.42
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
- gh-152241
- gh-152578
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run PYTHON_JIT=0 ./python -m test -v test_c_stack_unwind on Linux LoongArch64 with both GCC and Clang, then inspect CPython's manually implemented frame-pointer unwinding and the test sections using GNU backtrace(). Done means the test recognizes LoongArch frame layout and the applicable Clang build tests no longer fail; linked PRs gh-152241 and gh-152578 indicate work is already underway.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, linux, python
- Domain
- compilers, operating-systems, testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100