@@ -400,33 +400,37 @@ def skip_if_buildbot(reason=None):
400400 isbuildbot = False
401401 return unittest .skipIf (isbuildbot , reason )
402402
403- def check_sanitizer (* , address = False , memory = False , ub = False ):
403+ def check_sanitizer (* , address = False , memory = False , ub = False , thread = False ):
404404 """Returns True if Python is compiled with sanitizer support"""
405- if not (address or memory or ub ):
406- raise ValueError ('At least one of address, memory, or ub must be True' )
405+ if not (address or memory or ub or thread ):
406+ raise ValueError ('At least one of address, memory, ub or thread must be True' )
407407
408408
409- _cflags = sysconfig .get_config_var ('CFLAGS' ) or ''
410- _config_args = sysconfig .get_config_var ('CONFIG_ARGS' ) or ''
409+ cflags = sysconfig .get_config_var ('CFLAGS' ) or ''
410+ config_args = sysconfig .get_config_var ('CONFIG_ARGS' ) or ''
411411 memory_sanitizer = (
412- '-fsanitize=memory' in _cflags or
413- '--with-memory-sanitizer' in _config_args
412+ '-fsanitize=memory' in cflags or
413+ '--with-memory-sanitizer' in config_args
414414 )
415415 address_sanitizer = (
416- '-fsanitize=address' in _cflags or
417- '--with-address-sanitizer' in _config_args
416+ '-fsanitize=address' in cflags or
417+ '--with-address-sanitizer' in config_args
418418 )
419419 ub_sanitizer = (
420- '-fsanitize=undefined' in _cflags or
421- '--with-undefined-behavior-sanitizer' in _config_args
420+ '-fsanitize=undefined' in cflags or
421+ '--with-undefined-behavior-sanitizer' in config_args
422+ )
423+ thread_sanitizer = (
424+ '-fsanitize=thread' in cflags or
425+ '--with-thread-sanitizer' in config_args
422426 )
423427 return (
424- (memory and memory_sanitizer ) or
425- (address and address_sanitizer ) or
426- (ub and ub_sanitizer )
428+ (memory and memory_sanitizer ) or
429+ (address and address_sanitizer ) or
430+ (ub and ub_sanitizer ) or
431+ (thread and thread_sanitizer )
427432 )
428433
429-
430434def skip_if_sanitizer (reason = None , * , address = False , memory = False , ub = False , thread = False ):
431435 """Decorator raising SkipTest if running with a sanitizer active."""
432436 if not reason :
@@ -2550,3 +2554,4 @@ def adjust_int_max_str_digits(max_digits):
25502554#Windows doesn't have os.uname() but it doesn't support s390x.
25512555skip_on_s390x = unittest .skipIf (hasattr (os , 'uname' ) and os .uname ().machine == 's390x' ,
25522556 'skipped on s390x' )
2557+ HAVE_ASAN_FORK_BUG = check_sanitizer (address = True )
0 commit comments