@@ -392,10 +392,10 @@ def skip_if_buildbot(reason=None):
392392 isbuildbot = False
393393 return unittest .skipIf (isbuildbot , reason )
394394
395- def check_sanitizer (* , address = False , memory = False , ub = False ):
395+ def check_sanitizer (* , address = False , memory = False , ub = False , thread = False ):
396396 """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' )
399399
400400
401401 cflags = sysconfig .get_config_var ('CFLAGS' ) or ''
@@ -412,18 +412,23 @@ def check_sanitizer(*, address=False, memory=False, ub=False):
412412 '-fsanitize=undefined' in cflags or
413413 '--with-undefined-behavior-sanitizer' in config_args
414414 )
415+ thread_sanitizer = (
416+ '-fsanitize=thread' in cflags or
417+ '--with-thread-sanitizer' in config_args
418+ )
415419 return (
416420 (memory and memory_sanitizer ) or
417421 (address and address_sanitizer ) or
418- (ub and ub_sanitizer )
422+ (ub and ub_sanitizer ) or
423+ (thread and thread_sanitizer )
419424 )
420425
421426
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 ):
423428 """Decorator raising SkipTest if running with a sanitizer active."""
424429 if not reason :
425430 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 )
427432 return unittest .skipIf (skip , reason )
428433
429434# 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):
432437
433438
434439def 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' ):
436441 if name in env :
437442 env [name ] += f':{ option } '
438443 else :
0 commit comments