Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/reusable-san.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ jobs:
run: make -j4
- name: Display build info
run: make pythoninfo
# test_{capi,faulthandler} are skipped under UBSan because
# test_capi is skipped under UBSan because
# they raise signals that UBSan with halt_on_error=1 intercepts.
- name: Tests
run: >-
./python -m test
${{ inputs.sanitizer == 'TSan' && '--tsan' || '' }}
${{ inputs.sanitizer == 'UBSan' && '-x test_capi -x test_faulthandler' || '' }}
${{ inputs.sanitizer == 'UBSan' && '-x test_capi' || '' }}
-j4 -W
- name: Parallel tests
if: >-
Expand Down
13 changes: 9 additions & 4 deletions Lib/test/test_faulthandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
CURRENT_THREAD_HEADER = fr'{CURRENT_THREAD_ID} \(most recent call first\):'


def skip_if_sanitizer_signal(signame):
return support.skip_if_sanitizer(f"TSAN/UBSan itercepts {signame}",
thread=True, ub=True)


def expected_traceback(lineno1, lineno2, header, min_count=1):
regex = header
regex += ' File "<string>", line %s in func\n' % lineno1
Expand Down Expand Up @@ -224,7 +229,7 @@ def test_fatal_error_c_thread(self):
func='faulthandler_fatal_error_thread',
py_fatal_error=True)

@support.skip_if_sanitizer("TSAN itercepts SIGABRT", thread=True)
@skip_if_sanitizer_signal("SIGABRT")
def test_sigabrt(self):
self.check_fatal_error("""
import faulthandler
Expand All @@ -236,7 +241,7 @@ def test_sigabrt(self):

@unittest.skipIf(sys.platform == 'win32',
"SIGFPE cannot be caught on Windows")
@support.skip_if_sanitizer("TSAN itercepts SIGFPE", thread=True)
@skip_if_sanitizer_signal("SIGFPE")
def test_sigfpe(self):
self.check_fatal_error("""
import faulthandler
Expand All @@ -248,7 +253,7 @@ def test_sigfpe(self):

@unittest.skipIf(_testcapi is None, 'need _testcapi')
@unittest.skipUnless(hasattr(signal, 'SIGBUS'), 'need signal.SIGBUS')
@support.skip_if_sanitizer("TSAN itercepts SIGBUS", thread=True)
@skip_if_sanitizer_signal("SIGBUS")
@skip_segfault_on_android
def test_sigbus(self):
self.check_fatal_error("""
Expand All @@ -263,7 +268,7 @@ def test_sigbus(self):

@unittest.skipIf(_testcapi is None, 'need _testcapi')
@unittest.skipUnless(hasattr(signal, 'SIGILL'), 'need signal.SIGILL')
@support.skip_if_sanitizer("TSAN itercepts SIGILL", thread=True)
@skip_if_sanitizer_signal("SIGILL")
@skip_segfault_on_android
def test_sigill(self):
self.check_fatal_error("""
Expand Down
4 changes: 3 additions & 1 deletion Python/pylifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -3731,7 +3731,9 @@ fatal_error(int fd, int header, const char *prefix, const char *msg,
This function already did its best to display a traceback.
Disable faulthandler to prevent writing a second traceback
on abort(). */
_PyFaulthandler_Fini();
if (has_tstate_and_gil) {
_PyFaulthandler_Fini();
}

/* Check if the current Python thread hold the GIL */
if (has_tstate_and_gil) {
Expand Down
Loading