This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: [2.7] test_regrtest.test_crashed() fails on s390x
Type: Stage: resolved
Components: Tests Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: cstratak, ishcherb, serhiy.storchaka, vstinner
Priority: normal Keywords: patch

Created on 2017-10-06 20:35 by vstinner, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 3912 merged vstinner, 2017-10-06 20:36
Messages (7)
msg303854 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-10-06 20:35
On the s390x architecture, the test_regrtest.test_crashed() fails because Python doesn't crash.

test.support._crash_python() calls ctypes.string_at(0) to crash Python. In debug mode, ctypes.string_at(0) fails with an assertion error and the process is killed with the SIGABRT signal. In release mode, ctypes.string_at(0) returns an empty string but doesn't crash.

Attached PR adds a new _testcapi._read_null() function which does crash in a reliable way on s390x and x86 :-) The function uses the C "volatile" keyword to prevent compiler optimizations. I copied the code from my faulthandler._read_null() function in the master branch which was battle tested. It does crash on all platforms... except of AIX.
msg303926 - (view) Author: Iryna Shcherbina (ishcherb) * Date: 2017-10-09 07:20
I have run a build with the patch applied, and can confirm that the tests  pass on s390x.
Full build log can be viewed here: https://kojipkgs.fedoraproject.org//work/tasks/9473/22339473/build.log
msg303930 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-10-09 07:52
New changeset cc4b6f1c6210460c0645b1df508e114e16805784 by Victor Stinner in branch '2.7':
bpo-31719: Fix test_regrtest.test_crashed() on s390x (#3912)
https://github.com/python/cpython/commit/cc4b6f1c6210460c0645b1df508e114e16805784
msg303931 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-10-09 07:56
For the records, test_regrtest.test_crashed() uses faulthandler._sigsegv() in the master branch. This function calls raise(SIGSEGV) directly, rather than trying to read from NULL (address 0).
msg303932 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-10-09 08:24
The main issue with reading from NULL is that it may not crash on AIX.  But I checked: test_regrtest passed on our AIX buildbot.
msg303994 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-10-09 19:31
Why not use just abort() or Py_FatalError()?

$ ./python -c 'import ctypes; ctypes.CDLL("libc.so.6").abort()'
Aborted (core dumped)

$ ./python -c 'import ctypes; ctypes.pythonapi.Py_FatalError(b"boom!")'
Fatal Python error: boom!

Current thread 0x00007f26805c7580 (most recent call first):
  File "<string>", line 1 in <module>
Aborted (core dumped)
msg304038 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-10-10 13:14
> Why not use just abort() or Py_FatalError()?

I try to test how a real program crash, like a real invalid memory read. Maybe it doesn't matter much here.
History
Date User Action Args
2022-04-11 14:58:53adminsetgithub: 75900
2017-10-10 13:14:48vstinnersetmessages: + msg304038
2017-10-09 19:31:45serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg303994
2017-10-09 08:24:27vstinnersetmessages: + msg303932
2017-10-09 07:56:03vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg303931

stage: patch review -> resolved
2017-10-09 07:52:12vstinnersetmessages: + msg303930
2017-10-09 07:20:11ishcherbsetmessages: + msg303926
2017-10-06 20:39:01vstinnersetnosy: + cstratak, ishcherb
2017-10-06 20:36:28vstinnersetkeywords: + patch
stage: patch review
pull_requests: + pull_request3885
2017-10-06 20:35:01vstinnercreate