@@ -392,10 +392,10 @@ def skip_if_buildbot(reason=None):
392
392
isbuildbot = False
393
393
return unittest .skipIf (isbuildbot , reason )
394
394
395
- def check_sanitizer (* , address = False , memory = False , ub = False ):
395
+ def check_sanitizer (* , address = False , memory = False , ub = False , thread = False ):
396
396
"""Returns True if Python is compiled with sanitizer support"""
397
- if not (address or memory or ub ):
398
- raise ValueError ('At least one of address, memory, or ub must be True' )
397
+ if not (address or memory or ub or thread ):
398
+ raise ValueError ('At least one of address, memory, ub or thread must be True' )
399
399
400
400
401
401
cflags = sysconfig .get_config_var ('CFLAGS' ) or ''
@@ -412,18 +412,23 @@ def check_sanitizer(*, address=False, memory=False, ub=False):
412
412
'-fsanitize=undefined' in cflags or
413
413
'--with-undefined-behavior-sanitizer' in config_args
414
414
)
415
+ thread_sanitizer = (
416
+ '-fsanitize=thread' in cflags or
417
+ '--with-thread-sanitizer' in config_args
418
+ )
415
419
return (
416
420
(memory and memory_sanitizer ) or
417
421
(address and address_sanitizer ) or
418
- (ub and ub_sanitizer )
422
+ (ub and ub_sanitizer ) or
423
+ (thread and thread_sanitizer )
419
424
)
420
425
421
426
422
- def skip_if_sanitizer (reason = None , * , address = False , memory = False , ub = False ):
427
+ def skip_if_sanitizer (reason = None , * , address = False , memory = False , ub = False , thread = False ):
423
428
"""Decorator raising SkipTest if running with a sanitizer active."""
424
429
if not reason :
425
430
reason = 'not working with sanitizers active'
426
- skip = check_sanitizer (address = address , memory = memory , ub = ub )
431
+ skip = check_sanitizer (address = address , memory = memory , ub = ub , thread = thread )
427
432
return unittest .skipIf (skip , reason )
428
433
429
434
# gh-89363: True if fork() can hang if Python is built with Address Sanitizer
@@ -432,7 +437,7 @@ def skip_if_sanitizer(reason=None, *, address=False, memory=False, ub=False):
432
437
433
438
434
439
def set_sanitizer_env_var (env , option ):
435
- for name in ('ASAN_OPTIONS' , 'MSAN_OPTIONS' , 'UBSAN_OPTIONS' ):
440
+ for name in ('ASAN_OPTIONS' , 'MSAN_OPTIONS' , 'UBSAN_OPTIONS' , 'TSAN_OPTIONS' ):
436
441
if name in env :
437
442
env [name ] += f':{ option } '
438
443
else :
0 commit comments