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, haypo, ishcherb, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2017-10-06 20:35 by haypo, last changed 2017-10-10 13:14 by haypo. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 3912 merged haypo, 2017-10-06 20:36
Messages (7)
msg303854 - (view) Author: STINNER Victor (haypo) * (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 (haypo) * (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 (haypo) * (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 (haypo) * (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 (haypo) * (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
2017-10-10 13:14:48hayposetmessages: + msg304038
2017-10-09 19:31:45serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg303994
2017-10-09 08:24:27hayposetmessages: + msg303932
2017-10-09 07:56:03hayposetstatus: open -> closed
resolution: fixed
messages: + msg303931

stage: patch review -> resolved
2017-10-09 07:52:12hayposetmessages: + msg303930
2017-10-09 07:20:11ishcherbsetmessages: + msg303926
2017-10-06 20:39:01hayposetnosy: + cstratak, ishcherb
2017-10-06 20:36:28hayposetkeywords: + patch
stage: patch review
pull_requests: + pull_request3885
2017-10-06 20:35:01haypocreate