From 7d36f9be2ee16de3b0440e4daf5f966dbce99b8e Mon Sep 17 00:00:00 2001 From: Charlie Lin Date: Mon, 20 Apr 2026 17:14:10 -0500 Subject: [PATCH 1/2] Add support for various sanitizers in configure.ac --- configure.ac | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) diff --git a/configure.ac b/configure.ac index 7b6f3c5e0ed5be..0698391365a512 100644 --- a/configure.ac +++ b/configure.ac @@ -3394,6 +3394,76 @@ with_pymalloc="no" ], [AC_MSG_RESULT([no])]) +AC_MSG_CHECKING([for --with-hwaddress-sanitizer]) +AC_ARG_WITH([hwaddress_sanitizer], + AS_HELP_STRING([--with-hwaddress-sanitizer], + [enable hardware-assisted AddressSanitizer memory error detector on arm64, 'hwasan' (default is no)]), +[ +if test "$withval" != no; then + case "$host" in + aarch64*): + BASECFLAGS="-fsanitize=hwaddress -fno-omit-frame-pointer $BASECFLAGS" + LDFLAGS="-fsanitize=hwaddress $LDFLAGS" + # ASan works by controlling memory allocation, our own malloc interferes. + with_pymalloc="no" + AC_MSG_RESULT([yes]) + ;; + *): + AC_MSG_RESULT([only available on ARM64]) + ;; + esac +fi +] + +AC_MSG_CHECKING([for --with-memory-tagging]) +AC_ARG_WITH([hwaddress_sanitizer], + AS_HELP_STRING([--with-memory-tagging], + [enable Memory Tagging Extension for arm64 to detect memory errors (default is no)]), +[ +if test "$withval" != no; then + case "$host" in + aarch64*): + BASECFLAGS="-fsanitize=memtag-stack -fno-omit-frame-pointer $BASECFLAGS" + LDFLAGS="-fsanitize=memtag-stack $LDFLAGS" + # ASan works by controlling memory allocation, our own malloc interferes. + with_pymalloc="no" + AC_MSG_RESULT([yes]) + ;; + *): + AC_MSG_RESULT([only available on ARM64]) + ;; + esac +fi +] + +AC_MSG_CHECKING([for --sanitize-pointer-comparison]) +AC_ARG_WITH([sanitize_pointer_compare], + AS_HELP_STRING([--sanitize-pointer-comparison], + [Instrument pointer comparison operation (<, <=, >, >=). + Must be combined with --with-address-sanitizer, + and can't combined with --with-thread-sanitizer (default is no)]), +[ +AC_MSG_RESULT([$withval]) +BASECFLAGS="-fsanitize=pointer-compare -fno-omit-frame-pointer $BASECFLAGS" +LDFLAGS="-fsanitize=pointer-compare $LDFLAGS" +ASAN_OPTIONS="detect_invalid_pointer_pairs=2 $ASAN_OPTIONS" +], +[AC_MSG_RESULT([no])]) + +AC_MSG_CHECKING([for --sanitize-pointer-subtraction]) +AC_ARG_WITH([sanitize_pointer_compare], + AS_HELP_STRING([--sanitize-pointer-substraction], + [Instrument pointer subtraction. + Must be combined with --with-address-sanitizer, + and can't combined with --with-thread-sanitizer (default is no)]), +[ +AC_MSG_RESULT([$withval]) +BASECFLAGS="-fsanitize=pointer-compare -fno-omit-frame-pointer $BASECFLAGS" +LDFLAGS="-fsanitize=pointer-compare $LDFLAGS" +ASAN_OPTIONS="detect_invalid_pointer_pairs=2 $ASAN_OPTIONS" +], +[AC_MSG_RESULT([no])]) + AC_MSG_CHECKING([for --with-memory-sanitizer]) AC_ARG_WITH( [memory_sanitizer], @@ -3430,6 +3500,40 @@ AC_MSG_RESULT([no]) with_ubsan="no" ]) +AC_MSG_CHECKING([for --with-leak-sanitizer]) +AC_ARG_WITH( + [leak_sanitizer], + [AS_HELP_STRING( + [--with-leak-sanitizer], + [enable LeakSanitizer memory leak detector, 'lsan' (default is no)] + )], +[ +AC_MSG_RESULT([$withval]) +BASECFLAGS="-fsanitize=leak $BASECFLAGS" +LDFLAGS="-fsanitize=leak $LDFLAGS" +with_lsan="yes" +], +[ +AC_MSG_RESULT([no]) +with_lsan="no" +]) + +AC_MSG_CHECKING([for --sanitize-address-use-after-scope]) +AC_ARG_WITH( + [sanitize-address-use-after-scope], + [AS_HELP_STRING( + [--sanitize-address-use-after-scope], + [sanitize local variales to detect use-after-scope bugs (default is no)] + )], +[ +AC_MSG_RESULT([$withval]) +BASECFLAGS="-fsanitize-address-use-after-scope $BASECFLAGS" +LDFLAGS="-fsanitize-address-use-after-scope $LDFLAGS" +], +[ +AC_MSG_RESULT([no]) +]) + AC_MSG_CHECKING([for --with-thread-sanitizer]) AC_ARG_WITH( [thread_sanitizer], From ee830ab8c8240d683f21fa6299aa88cd4d8be147 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Mon, 20 Apr 2026 22:16:13 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Build/2026-04-20-22-16-09.gh-issue-148810.wVS_E7.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Build/2026-04-20-22-16-09.gh-issue-148810.wVS_E7.rst diff --git a/Misc/NEWS.d/next/Build/2026-04-20-22-16-09.gh-issue-148810.wVS_E7.rst b/Misc/NEWS.d/next/Build/2026-04-20-22-16-09.gh-issue-148810.wVS_E7.rst new file mode 100644 index 00000000000000..2327ad895487fc --- /dev/null +++ b/Misc/NEWS.d/next/Build/2026-04-20-22-16-09.gh-issue-148810.wVS_E7.rst @@ -0,0 +1 @@ +Add configuration options to enable more sanitizers supported by GCC