Skip to content

Commit 9204bb7

Browse files
authored
bpo-46633: Skip tests on ASAN and/or MSAN builds (GH-31632)
Skip tests on ASAN and/or MSAN builds: * multiprocessing tests * test___all__ * test_concurrent_futures * test_decimal * test_peg_generator * test_tools The ASAN job of GitHub Actions no longer excludes these tests.
1 parent 0cc6364 commit 9204bb7

File tree

7 files changed

+40
-24
lines changed

7 files changed

+40
-24
lines changed

.github/workflows/build.yml

+1-9
Original file line numberDiff line numberDiff line change
@@ -306,12 +306,4 @@ jobs:
306306
- name: Display build info
307307
run: make pythoninfo
308308
- name: Tests
309-
# Skip test_tools test_peg_generator test_concurrent_futures because
310-
# there are too slow: between 5 and 20 minutes on this CI.
311-
#
312-
# Skip multiprocessing and concurrent.futures tests which are affected by
313-
# bpo-45200 bug: libasan dead lock in pthread_create().
314-
#
315-
# test___all__ is skipped because importing some modules directly can trigger
316-
# known problems with ASAN (like tk or crypt).
317-
run: xvfb-run make buildbottest TESTOPTS="-j4 -uall,-cpu -x test___all__ test_multiprocessing_fork test_multiprocessing_forkserver test_multiprocessing_spawn test_tools test_peg_generator test_concurrent_futures"
309+
run: xvfb-run make buildbottest TESTOPTS="-j4 -uall,-cpu"

Lib/test/_test_multiprocessing.py

+6
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@
7373
msvcrt = None
7474

7575

76+
if support.check_sanitizer(address=True):
77+
# bpo-45200: Skip multiprocessing tests if Python is built with ASAN to
78+
# work around a libasan race condition: dead lock in pthread_create().
79+
raise unittest.SkipTest("libasan has a pthread_create() dead lock")
80+
81+
7682
def latin(s):
7783
return s.encode('latin')
7884

Lib/test/test___all__.py

+7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111
_multiprocessing = None
1212

1313

14+
if support.check_sanitizer(address=True, memory=True):
15+
# bpo-46633: test___all__ is skipped because importing some modules
16+
# directly can trigger known problems with ASAN (like tk or crypt).
17+
raise unittest.SkipTest("workaround ASAN build issues on loading tests "
18+
"like tk or crypt")
19+
20+
1421
class NoAll(RuntimeError):
1522
pass
1623

Lib/test/test_concurrent_futures.py

+6
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@
3232
import multiprocessing.util
3333

3434

35+
if support.check_sanitizer(address=True, memory=True):
36+
# bpo-46633: Skip the test because it is too slow when Python is built
37+
# with ASAN/MSAN: between 5 and 20 minutes on GitHub Actions.
38+
raise unittest.SkipTest("test too slow on ASAN/MSAN build")
39+
40+
3541
def create_future(state=PENDING, exception=None, result=None):
3642
f = Future()
3743
f._state = state

Lib/test/test_decimal.py

+3-13
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import locale
3535
from test.support import (run_unittest, run_doctest, is_resource_enabled,
3636
requires_IEEE_754, requires_docstrings,
37-
requires_legacy_unicode_capi)
37+
requires_legacy_unicode_capi, check_sanitizer)
3838
from test.support import (TestFailed,
3939
run_with_locale, cpython_only,
4040
darwin_malloc_err_warning)
@@ -43,17 +43,6 @@
4343
import random
4444
import inspect
4545
import threading
46-
import sysconfig
47-
_cflags = sysconfig.get_config_var('CFLAGS') or ''
48-
_config_args = sysconfig.get_config_var('CONFIG_ARGS') or ''
49-
MEMORY_SANITIZER = (
50-
'-fsanitize=memory' in _cflags or
51-
'--with-memory-sanitizer' in _config_args
52-
)
53-
54-
ADDRESS_SANITIZER = (
55-
'-fsanitize=address' in _cflags
56-
)
5746

5847

5948
if sys.platform == 'darwin':
@@ -5518,7 +5507,8 @@ def __abs__(self):
55185507
# Issue 41540:
55195508
@unittest.skipIf(sys.platform.startswith("aix"),
55205509
"AIX: default ulimit: test is flaky because of extreme over-allocation")
5521-
@unittest.skipIf(MEMORY_SANITIZER or ADDRESS_SANITIZER, "sanitizer defaults to crashing "
5510+
@unittest.skipIf(check_sanitizer(address=True, memory=True),
5511+
"ASAN/MSAN sanitizer defaults to crashing "
55225512
"instead of returning NULL for malloc failure.")
55235513
def test_maxcontext_exact_arith(self):
55245514

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1-
import os
2-
1+
import os.path
2+
import unittest
3+
from test import support
34
from test.support import load_package_tests
45

6+
7+
if support.check_sanitizer(address=True, memory=True):
8+
# bpo-46633: Skip the test because it is too slow when Python is built
9+
# with ASAN/MSAN: between 5 and 20 minutes on GitHub Actions.
10+
raise unittest.SkipTest("test too slow on ASAN/MSAN build")
11+
12+
513
# Load all tests in package
614
def load_tests(*args):
715
return load_package_tests(os.path.dirname(__file__), *args)

Lib/test/test_tools/__init__.py

+7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
from test import support
77
from test.support import import_helper
88

9+
10+
if support.check_sanitizer(address=True, memory=True):
11+
# bpo-46633: Skip the test because it is too slow when Python is built
12+
# with ASAN/MSAN: between 5 and 20 minutes on GitHub Actions.
13+
raise unittest.SkipTest("test too slow on ASAN/MSAN build")
14+
15+
916
basepath = os.path.normpath(
1017
os.path.dirname( # <src/install dir>
1118
os.path.dirname( # Lib

0 commit comments

Comments
 (0)