Skip to content

test_c_stack_unwind fails on AArch64 with pointer authentication enabled #160102

Open

Description

@mcepl

Bug report

Bug description

Building CPython 3.15.0 on openSUSE for AArch64 fails in test_c_stack_unwind.ManualStackUnwindTests.test_manual_unwind_finds_expected_frames. Intel builds pass.

The test fails with both PYTHON_JIT=0 and PYTHON_JIT=1:

AssertionError: 1 not greater than or equal to 10 : expected to find Python frames on aarch64 with env {'PYTHON_JIT': '0'}

AssertionError: 0 not greater than 0 : expected to find JIT frames on aarch64 with env {'PYTHON_JIT': '1'}

The build uses these compiler flags, among others:

-mbranch-protection=standard
-fno-omit-frame-pointer
-mno-omit-leaf-frame-pointer
-O2
-flto

Relevant configure options:

--enable-shared
--with-lto
--enable-experimental-jit=yes-off

The unwinder appears to read saved return addresses without stripping AArch64 pointer-authentication bits. These signed addresses then fail classification against Python and JIT code ranges.

For example, the test reports:

JIT ranges:
  0xffff8303d000-0xffff8303f000

but classifies return addresses such as:

#05 0x71ffff8303d9f0 -> other
#10 0x27ffff8303d9f0 -> other
#15 0x64ffff8303d9f0 -> other

Without the authentication bits, each is 0xffff8303d9f0, which lies inside the reported JIT range.

The corresponding summary is:

{"length": 62, "python_frames": 10, "jit_frames": 0, "other_frames": 52, "jit_backend": "jit", "unwinder": "manual_frame_pointer_unwind"}

In Modules/_testinternalcapi.c, manual_unwind_from_fp() reads the saved address directly:

uintptr_t return_addr = frame_pointer[FRAME_POINTER_RETURN_OFFSET];

It then converts that raw value to a Python integer without removing pointer-authentication bits.

It looks like the manual unwinder needs to strip these bits before returning addresses for classification. Frame pointers are already enabled in this build.

This is related to #126910, but appears distinct from #151602, where frame-pointer omission causes the same test to fail.

Related to #152240, which fixes architecture-specific failures in the same test on LoongArch. This AArch64 failure appears different: the frame chain is traversed successfully, but saved return addresses retain pointer-authentication bits and therefore fail code-range classification.

Package sources: https://src.opensuse.org/python-interpreters/python315

CPython versions tested on:

3.15.0 and 3.16.0~a1

Operating systems tested on:

Linux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    testsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions