From 6a0ff6335de4d2f5a9482209317e36718e01f8d9 Mon Sep 17 00:00:00 2001 From: Illia Volochii Date: Mon, 20 Mar 2023 09:35:17 +0200 Subject: [PATCH 1/2] gh-102509: Create an ignore list for sanitizers --- Misc/README | 1 + Misc/sanitize-ignorelist.txt | 12 ++++++++++++ configure | 4 ++-- configure.ac | 4 ++-- 4 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 Misc/sanitize-ignorelist.txt diff --git a/Misc/README b/Misc/README index e4dd2005411a8d..bc39aee2f1430f 100644 --- a/Misc/README +++ b/Misc/README @@ -20,6 +20,7 @@ README The file you're reading now README.AIX Information about using Python on AIX README.coverity Information about running Coverity's Prevent on Python README.valgrind Information for Valgrind users, see valgrind-python.supp +sanitize-ignorelist.txt Entities to be ignored by sanitizers SpecialBuilds.txt Describes extra symbols you can set for debug builds svnmap.txt Map of old SVN revs and branches to hg changeset ids, help history-digging diff --git a/Misc/sanitize-ignorelist.txt b/Misc/sanitize-ignorelist.txt new file mode 100644 index 00000000000000..ae39f572cfb216 --- /dev/null +++ b/Misc/sanitize-ignorelist.txt @@ -0,0 +1,12 @@ +# +# This is a file listing entities to be ignored by sanitizers. +# https://clang.llvm.org/docs/SanitizerSpecialCaseList.html +# + +[memory] +# medium_value called by maybe_small_long accesses an uninitialized +# integer in the case of PyLong of size 0, but the integer is then +# multiplied by zero immediately, so the lack of initialisation has no +# adverse effect. +# https://github.com/python/cpython/issues/102509 +fun:maybe_small_long diff --git a/configure b/configure index 9e99352f589f21..85f8d2daf017a4 100755 --- a/configure +++ b/configure @@ -11174,8 +11174,8 @@ fi $as_echo "$ax_cv_check_cflags___fsanitize_memory" >&6; } if test "x$ax_cv_check_cflags___fsanitize_memory" = xyes; then : -BASECFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer $BASECFLAGS" -LDFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 $LDFLAGS" +BASECFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer -fsanitize-ignorelist=Misc/sanitize-ignorelist.txt $BASECFLAGS" +LDFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 -fsanitize-ignorelist=Misc/sanitize-ignorelist.txt $LDFLAGS" else as_fn_error $? "The selected compiler doesn't support memory sanitizer" "$LINENO" 5 diff --git a/configure.ac b/configure.ac index 31b7a2157a2bcc..bba9494042ec6b 100644 --- a/configure.ac +++ b/configure.ac @@ -3081,8 +3081,8 @@ AC_ARG_WITH(memory_sanitizer, [ AC_MSG_RESULT($withval) AX_CHECK_COMPILE_FLAG([-fsanitize=memory],[ -BASECFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer $BASECFLAGS" -LDFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 $LDFLAGS" +BASECFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer -fsanitize-ignorelist=Misc/sanitize-ignorelist.txt $BASECFLAGS" +LDFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 -fsanitize-ignorelist=Misc/sanitize-ignorelist.txt $LDFLAGS" ],[AC_MSG_ERROR([The selected compiler doesn't support memory sanitizer])]) # MSan works by controlling memory allocation, our own malloc interferes. with_pymalloc="no" From 01b6e1d8edc6517a736f4a729f0a94f478399394 Mon Sep 17 00:00:00 2001 From: Illia Volochii Date: Mon, 20 Mar 2023 09:48:29 +0200 Subject: [PATCH 2/2] Add a news entry --- .../next/Build/2023-03-20-09-47-46.gh-issue-102838.k3MRiC.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Build/2023-03-20-09-47-46.gh-issue-102838.k3MRiC.rst diff --git a/Misc/NEWS.d/next/Build/2023-03-20-09-47-46.gh-issue-102838.k3MRiC.rst b/Misc/NEWS.d/next/Build/2023-03-20-09-47-46.gh-issue-102838.k3MRiC.rst new file mode 100644 index 00000000000000..2a1c3c8617241c --- /dev/null +++ b/Misc/NEWS.d/next/Build/2023-03-20-09-47-46.gh-issue-102838.k3MRiC.rst @@ -0,0 +1,2 @@ +Ignore acceptable access of an uninitialized value to fix building +``--with-memory-sanitizer``. Patch by Illia Volochii.