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: test_faulthandler fails on Mac OS X Lion
Type: behavior Stage:
Components: Tests Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: gdr@garethrees.org, python-dev, vstinner
Priority: normal Keywords: easy

Created on 2011-08-05 23:18 by gdr@garethrees.org, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (7)
msg141695 - (view) Author: Gareth Rees (gdr@garethrees.org) * (Python triager) Date: 2011-08-05 23:18
On Mac OS 10.7, test_faulthandler fails. See test output below.

It looks as though the tests may be at fault in expecting to see "(?:Segmentation fault|Bus error)" instead of "(?:Segmentation fault|Bus error|Illegal instruction)".

    test_disable (__main__.FaultHandlerTests) ... ok
    test_dump_traceback (__main__.FaultHandlerTests) ... ok
    test_dump_traceback_file (__main__.FaultHandlerTests) ... ok
    test_dump_traceback_threads (__main__.FaultHandlerTests) ... ok
    test_dump_traceback_threads_file (__main__.FaultHandlerTests) ... ok
    test_dump_tracebacks_later (__main__.FaultHandlerTests) ... ok
    test_dump_tracebacks_later_cancel (__main__.FaultHandlerTests) ... ok
    test_dump_tracebacks_later_file (__main__.FaultHandlerTests) ... ok
    test_dump_tracebacks_later_repeat (__main__.FaultHandlerTests) ... ok
    test_dump_tracebacks_later_twice (__main__.FaultHandlerTests) ... ok
    test_enable_file (__main__.FaultHandlerTests) ... FAIL
    test_enable_single_thread (__main__.FaultHandlerTests) ... FAIL
    test_fatal_error (__main__.FaultHandlerTests) ... ok
    test_gil_released (__main__.FaultHandlerTests) ... FAIL
    test_is_enabled (__main__.FaultHandlerTests) ... ok
    test_read_null (__main__.FaultHandlerTests) ... FAIL
    test_register (__main__.FaultHandlerTests) ... ok
    test_register_chain (__main__.FaultHandlerTests) ... ok
    test_register_file (__main__.FaultHandlerTests) ... ok
    test_register_threads (__main__.FaultHandlerTests) ... ok
    test_sigabrt (__main__.FaultHandlerTests) ... ok
    test_sigbus (__main__.FaultHandlerTests) ... ok
    test_sigfpe (__main__.FaultHandlerTests) ... ok
    test_sigill (__main__.FaultHandlerTests) ... ok
    test_sigsegv (__main__.FaultHandlerTests) ... ok
    test_stack_overflow (__main__.FaultHandlerTests) ... ok
    test_unregister (__main__.FaultHandlerTests) ... ok

    ======================================================================
    FAIL: test_enable_file (__main__.FaultHandlerTests)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "test_faulthandler.py", line 207, in test_enable_file
        filename=filename)
      File "test_faulthandler.py", line 105, in check_fatal_error
        self.assertRegex(output, regex)
    AssertionError: Regex didn't match: '^Fatal Python error: (?:Segmentation fault|Bus error)\n\nCurrent\\ thread\\ XXX:\n  File "<string>", line 4 in <module>$' not found in 'Fatal Python error: Illegal instruction\n\nCurrent thread XXX:\n  File "<string>", line 4 in <module>'

    ======================================================================
    FAIL: test_enable_single_thread (__main__.FaultHandlerTests)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "test_faulthandler.py", line 217, in test_enable_single_thread
        all_threads=False)
      File "test_faulthandler.py", line 105, in check_fatal_error
        self.assertRegex(output, regex)
    AssertionError: Regex didn't match: '^Fatal Python error: (?:Segmentation fault|Bus error)\n\nTraceback\\ \\(most\\ recent\\ call\\ first\\):\n  File "<string>", line 3 in <module>$' not found in 'Fatal Python error: Illegal instruction\n\nTraceback (most recent call first):\n  File "<string>", line 3 in <module>'

    ======================================================================
    FAIL: test_gil_released (__main__.FaultHandlerTests)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "test_faulthandler.py", line 195, in test_gil_released
        '(?:Segmentation fault|Bus error)')
      File "test_faulthandler.py", line 105, in check_fatal_error
        self.assertRegex(output, regex)
    AssertionError: Regex didn't match: '^Fatal Python error: (?:Segmentation fault|Bus error)\n\nCurrent\\ thread\\ XXX:\n  File "<string>", line 3 in <module>$' not found in 'Fatal Python error: Illegal instruction\n\nCurrent thread XXX:\n  File "<string>", line 3 in <module>'

    ======================================================================
    FAIL: test_read_null (__main__.FaultHandlerTests)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "test_faulthandler.py", line 115, in test_read_null
        '(?:Segmentation fault|Bus error)')
      File "test_faulthandler.py", line 105, in check_fatal_error
        self.assertRegex(output, regex)
    AssertionError: Regex didn't match: '^Fatal Python error: (?:Segmentation fault|Bus error)\n\nCurrent\\ thread\\ XXX:\n  File "<string>", line 3 in <module>$' not found in 'Fatal Python error: Illegal instruction\n\nCurrent thread XXX:\n  File "<string>", line 3 in <module>'

    ----------------------------------------------------------------------
    Ran 27 tests in 21.711s

    FAILED (failures=4)
    Traceback (most recent call last):
      File "test_faulthandler.py", line 550, in <module>
        test_main()
      File "test_faulthandler.py", line 547, in test_main
        support.run_unittest(FaultHandlerTests)
      File "/Users/gdr/hg.python.org/cpython/Lib/test/support.py", line 1327, in run_unittest
        _run_suite(suite)
      File "/Users/gdr/hg.python.org/cpython/Lib/test/support.py", line 1302, in _run_suite
        raise TestFailed(err)
    test.support.TestFailed: multiple errors occurred
msg141762 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011-08-08 08:56
test_enable_file, test_enable_single_thread, test_gil_released and test_read_null read an int (4 bytes) from the address 0 (NULL).

test_sigsegv pass: this test raises explicitly a SIGSEGV and the signal handler writes the right message ("Segmentation fault").

Mac OS X Lion raises maybe a SIGILL on a segmentation fault if the address is zero? I suppose that it raises a SIGSEGV if the address is not zero.

Can you try to modify the function faulthandler_read_null() in Modules/faulthandler.c: replace "int *x = NULL, y;" by "int *x = (int *)1, y;" ? Then recompile (make) and rerun the test (./python.exe -m test -v test_faulthandler).
msg141797 - (view) Author: Gareth Rees (gdr@garethrees.org) * (Python triager) Date: 2011-08-08 20:24
After changing NULL to (int *)1, all tests pass.
msg141799 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-08-08 20:44
New changeset 1777df2ce50d by Victor Stinner in branch 'default':
Issue #12700: fix test_faulthandler for Mac OS X Lion
http://hg.python.org/cpython/rev/1777df2ce50d
msg141800 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011-08-08 20:47
> After changing NULL to (int *)1, all tests pass.

Ok, so Lion has a special case for reading from NULL. I changed the tests to try to fix your bug. Can you tell me if it's now better?
msg141802 - (view) Author: Gareth Rees (gdr@garethrees.org) * (Python triager) Date: 2011-08-08 21:12
All tests now pass.
msg141803 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011-08-08 21:17
> All tests now pass.

Ok, thanks for your report and your feedback.
History
Date User Action Args
2022-04-11 14:57:20adminsetgithub: 56909
2011-08-08 21:17:07vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg141803
2011-08-08 21:12:55gdr@garethrees.orgsetmessages: + msg141802
2011-08-08 20:47:03vstinnersetmessages: + msg141800
2011-08-08 20:44:32python-devsetnosy: + python-dev
messages: + msg141799
2011-08-08 20:24:09gdr@garethrees.orgsetmessages: + msg141797
2011-08-08 08:56:41vstinnersetmessages: + msg141762
2011-08-08 07:30:37pitrousetkeywords: + easy
nosy: + vstinner
2011-08-05 23:18:34gdr@garethrees.orgcreate