python / python/cpython

test_c_stack_unwind fails on Linux LoongArch builds

未关闭
#152,240 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

OS-unsupported tests type-bug
主要语言
Python
星标
77.2k
派生
35.9k
PR 合并指标
PR 指标待抓取

描述

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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

在 Linux LoongArch64 上分别使用 GCC 和 Clang 运行 PYTHON_JIT=0 ./python -m test -v test_c_stack_unwind,然后检查 CPython 手动实现的帧指针展开,以及使用 GNU backtrace() 的测试部分。测试能够识别 LoongArch 帧布局,且适用的 Clang 构建测试不再失败,即表示完成;已链接的 PR gh-152241 和 gh-152578 表明相关工作已经在进行中。

由索引模型根据 Issue 内容生成。

评估

技术栈
c, linux, python
领域
compilers, operating-systems, testing-qa
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。