Skip to content

gh-151040: Fix test_c_stack_unwind on riscv64#152370

Merged
vstinner merged 2 commits into
python:mainfrom
ByteFlowing1337:fix-151040
Jun 29, 2026
Merged

gh-151040: Fix test_c_stack_unwind on riscv64#152370
vstinner merged 2 commits into
python:mainfrom
ByteFlowing1337:fix-151040

Conversation

@ByteFlowing1337

@ByteFlowing1337 ByteFlowing1337 commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

According to https://riscv-non-isa.github.io/riscv-elf-psabi-doc/#_frame_pointer_convention, riscv64 puts the return address at fp[-1], and the previous frame pointer at fp[-2].

I verified this fix by using GCC to build CPython, and successfully ran ./python -m test -v test_c_stack_unwind via Docker and QEMU (docker run --platform linux/riscv64 riscv64/ubuntu:24.04). Tests passed.

@StanFromIreland

Copy link
Copy Markdown
Member

Since this is the same as #152241, closing in favour of the older PR.

@StanFromIreland

Copy link
Copy Markdown
Member

Ok, #152241 was merged. Please merge it with your addition here.

@vstinner

Copy link
Copy Markdown
Member

Since this is the same as #152241, closing in favour of the older PR.

IMO LoongArch is different enough from RISC-V that it deserves to have its own code path, see: https://en.wikipedia.org/wiki/Loongson#LoongArch. I merged the LoongArch PR (PR gh-152241).

Can you please solve the merge conflict on your PR?

@ByteFlowing1337

Copy link
Copy Markdown
Contributor Author

I have resolved the merge conflicts. I believe the issue reported in #150919 will also be fixed by this PR.

@StanFromIreland

Copy link
Copy Markdown
Member

!buildbot riscv64

@bedevere-bot

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @StanFromIreland for commit 6280ab1 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F152370%2Fmerge

The command will test the builders whose names match following regular expression: riscv64

The builders matched are:

  • riscv64 Ubuntu23 PR

@ByteFlowing1337

ByteFlowing1337 commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

test_c_stack_unwind passed on the buildbot, but the CI failed on test_sys . This has also occurred in previous riscv64 builds and is unrelated to this PR.

However, I cannot reproduce the test_sys failure locally using QEMU riscv64. It may be caused by the low performance of the buildbot's machine.

@vstinner

Copy link
Copy Markdown
Member

The test_sys failure is a timeout on running test_remote_exec_deleted_static_executable(). The test has a hardcoded timeout of 10 seconds.

0:46:03 load avg: 0.37 mem: 21.1 MiB [1/1/1] test_sys failed (1 error) (1 min 1 sec)
Re-running test_sys in verbose mode (matching: test_remote_exec_deleted_static_executable)
test_remote_exec_deleted_static_executable (test.test_sys.TestRemoteExec.test_remote_exec_deleted_static_executable)
Test remote exec when the target static executable was deleted. ... ERROR
/home/ubuntu/buildarea/pull_request.onder-riscv64.installed/build/target/lib/python3.16/unittest/case.py:690: ResourceWarning: unclosed <socket.socket fd=3, family=2, type=1, proto=0, laddr=('127.0.0.1', 55335)>
  with outcome.testPartExecutor(self):
ResourceWarning: Enable tracemalloc to get the object allocation traceback
======================================================================
ERROR: test_remote_exec_deleted_static_executable (test.test_sys.TestRemoteExec.test_remote_exec_deleted_static_executable)
Test remote exec when the target static executable was deleted.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ubuntu/buildarea/pull_request.onder-riscv64.installed/build/target/lib/python3.16/test/test_sys.py", line 2313, in test_remote_exec_deleted_static_executable
    self._run_remote_exec_with_deleted_mapping(
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        copied_python, python_args=['-S'],
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        python_executable=copied_python)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/buildarea/pull_request.onder-riscv64.installed/build/target/lib/python3.16/test/test_sys.py", line 2116, in _run_remote_exec_with_deleted_mapping
    returncode, stdout, stderr = self._run_remote_exec_test(
                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~^
        script, after_ready=delete_loaded_mapping, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/buildarea/pull_request.onder-riscv64.installed/build/target/lib/python3.16/test/test_sys.py", line 2078, in _run_remote_exec_test
    client_socket, _ = server_socket.accept()
                       ~~~~~~~~~~~~~~~~~~~~^^
  File "/home/ubuntu/buildarea/pull_request.onder-riscv64.installed/build/target/lib/python3.16/socket.py", line 299, in accept
    fd, addr = self._accept()
               ~~~~~~~~~~~~^^
TimeoutError: timed out
----------------------------------------------------------------------
Ran 1 test in 60.256s
FAILED (errors=1)
test test_sys failed

@vstinner vstinner added the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jun 29, 2026
@vstinner vstinner merged commit 1b0c05f into python:main Jun 29, 2026
74 of 75 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @ByteFlowing1337 for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Sorry, @ByteFlowing1337 and @vstinner, I could not cleanly backport this to 3.15 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 1b0c05f14807a43d070127b3d8eac1af8de27f28 3.15

@vstinner

Copy link
Copy Markdown
Member

Thanks for the fix @ByteFlowing1337!

For the backport to 3.15, I will wait until #152578 is merged to 3.15 first.

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

Labels

needs backport to 3.15 pre-release feature fixes, bugs and security fixes skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants