@@ -3394,6 +3394,76 @@ with_pymalloc="no"
33943394] ,
33953395[ AC_MSG_RESULT ( [ no] ) ] )
33963396
3397+ AC_MSG_CHECKING ( [ for --with-hwaddress-sanitizer] )
3398+ AC_ARG_WITH ( [ hwaddress_sanitizer] ,
3399+ AS_HELP_STRING ( [ --with-hwaddress-sanitizer] ,
3400+ [ enable hardware-assisted AddressSanitizer memory error detector on arm64, 'hwasan' (default is no)] ) ,
3401+ [
3402+ if test "$withval" != no; then
3403+ case "$host" in
3404+ aarch64*):
3405+ BASECFLAGS="-fsanitize=hwaddress -fno-omit-frame-pointer $BASECFLAGS"
3406+ LDFLAGS="-fsanitize=hwaddress $LDFLAGS"
3407+ # ASan works by controlling memory allocation, our own malloc interferes.
3408+ with_pymalloc="no"
3409+ AC_MSG_RESULT ( [ yes] )
3410+ ;;
3411+ *):
3412+ AC_MSG_RESULT ( [ only available on ARM64] )
3413+ ;;
3414+ esac
3415+ fi
3416+ ]
3417+
3418+ AC_MSG_CHECKING ( [ for --with-memory-tagging] )
3419+ AC_ARG_WITH ( [ hwaddress_sanitizer] ,
3420+ AS_HELP_STRING ( [ --with-memory-tagging] ,
3421+ [ enable Memory Tagging Extension for arm64 to detect memory errors (default is no)] ) ,
3422+ [
3423+ if test "$withval" != no; then
3424+ case "$host" in
3425+ aarch64*):
3426+ BASECFLAGS="-fsanitize=memtag-stack -fno-omit-frame-pointer $BASECFLAGS"
3427+ LDFLAGS="-fsanitize=memtag-stack $LDFLAGS"
3428+ # ASan works by controlling memory allocation, our own malloc interferes.
3429+ with_pymalloc="no"
3430+ AC_MSG_RESULT ( [ yes] )
3431+ ;;
3432+ *):
3433+ AC_MSG_RESULT ( [ only available on ARM64] )
3434+ ;;
3435+ esac
3436+ fi
3437+ ]
3438+
3439+ AC_MSG_CHECKING ( [ for --sanitize-pointer-comparison] )
3440+ AC_ARG_WITH ( [ sanitize_pointer_compare] ,
3441+ AS_HELP_STRING ( [ --sanitize-pointer-comparison] ,
3442+ [ Instrument pointer comparison operation (<, <=, >, >=).
3443+ Must be combined with --with-address-sanitizer,
3444+ and can't combined with --with-thread-sanitizer (default is no)] ) ,
3445+ [
3446+ AC_MSG_RESULT ( [ $withval] )
3447+ BASECFLAGS="-fsanitize=pointer-compare -fno-omit-frame-pointer $BASECFLAGS"
3448+ LDFLAGS="-fsanitize=pointer-compare $LDFLAGS"
3449+ ASAN_OPTIONS="detect_invalid_pointer_pairs=2 $ASAN_OPTIONS"
3450+ ] ,
3451+ [ AC_MSG_RESULT ( [ no] ) ] )
3452+
3453+ AC_MSG_CHECKING ( [ for --sanitize-pointer-subtraction] )
3454+ AC_ARG_WITH ( [ sanitize_pointer_compare] ,
3455+ AS_HELP_STRING ( [ --sanitize-pointer-substraction] ,
3456+ [ Instrument pointer subtraction.
3457+ Must be combined with --with-address-sanitizer,
3458+ and can't combined with --with-thread-sanitizer (default is no)] ) ,
3459+ [
3460+ AC_MSG_RESULT ( [ $withval] )
3461+ BASECFLAGS="-fsanitize=pointer-compare -fno-omit-frame-pointer $BASECFLAGS"
3462+ LDFLAGS="-fsanitize=pointer-compare $LDFLAGS"
3463+ ASAN_OPTIONS="detect_invalid_pointer_pairs=2 $ASAN_OPTIONS"
3464+ ] ,
3465+ [ AC_MSG_RESULT ( [ no] ) ] )
3466+
33973467AC_MSG_CHECKING ( [ for --with-memory-sanitizer] )
33983468AC_ARG_WITH (
33993469 [ memory_sanitizer] ,
@@ -3430,6 +3500,40 @@ AC_MSG_RESULT([no])
34303500with_ubsan="no"
34313501] )
34323502
3503+ AC_MSG_CHECKING ( [ for --with-leak-sanitizer] )
3504+ AC_ARG_WITH (
3505+ [ leak_sanitizer] ,
3506+ [ AS_HELP_STRING (
3507+ [ --with-leak-sanitizer] ,
3508+ [ enable LeakSanitizer memory leak detector, 'lsan' (default is no)]
3509+ ) ] ,
3510+ [
3511+ AC_MSG_RESULT ( [ $withval] )
3512+ BASECFLAGS="-fsanitize=leak $BASECFLAGS"
3513+ LDFLAGS="-fsanitize=leak $LDFLAGS"
3514+ with_lsan="yes"
3515+ ] ,
3516+ [
3517+ AC_MSG_RESULT ( [ no] )
3518+ with_lsan="no"
3519+ ] )
3520+
3521+ AC_MSG_CHECKING ( [ for --sanitize-address-use-after-scope] )
3522+ AC_ARG_WITH (
3523+ [ sanitize-address-use-after-scope] ,
3524+ [ AS_HELP_STRING (
3525+ [ --sanitize-address-use-after-scope] ,
3526+ [ sanitize local variales to detect use-after-scope bugs (default is no)]
3527+ ) ] ,
3528+ [
3529+ AC_MSG_RESULT ( [ $withval] )
3530+ BASECFLAGS="-fsanitize-address-use-after-scope $BASECFLAGS"
3531+ LDFLAGS="-fsanitize-address-use-after-scope $LDFLAGS"
3532+ ] ,
3533+ [
3534+ AC_MSG_RESULT ( [ no] )
3535+ ] )
3536+
34333537AC_MSG_CHECKING ( [ for --with-thread-sanitizer] )
34343538AC_ARG_WITH (
34353539 [ thread_sanitizer] ,
0 commit comments