summaryrefslogtreecommitdiff
path: root/Include
diff options
context:
space:
mode:
authorGregory P. Smith <greg@krypto.org>2018-11-12 13:48:24 -0800
committerGitHub <noreply@github.com>2018-11-12 13:48:24 -0800
commit5f4d05d83fde05fed0b6554d0beee4f1c1f1d8f1 (patch)
treed3ce1b9b4dc78d00b6318eb2be08a9ed0815d681 /Include
parentf3b0b91674f1790cc989d774a91fc7000918cce1 (diff)
downloadcpython-git-5f4d05d83fde05fed0b6554d0beee4f1c1f1d8f1.tar.gz
[3.7] bpo-35214: Initial clang MemorySanitizer support (GH-10479) (GH-10492)
Adds configure flags for msan and ubsan builds to make it easier to enable. These also encode the detail that address sanitizer and memory sanitizer should disable pymalloc. Define MEMORY_SANITIZER when appropriate at build time and adds workarounds to existing code to mark things as initialized where the sanitizer is otherwise unable to determine that. This lets our build succeed under the memory sanitizer. not all tests pass without sanitizer failures yet but we're in pretty good shape after this. (cherry picked from commit 1584a0081500d35dc93ff88e5836df35faf3e3e2) Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google LLC]
Diffstat (limited to 'Include')
-rw-r--r--Include/Python.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/Include/Python.h b/Include/Python.h
index 1feb1531cc..c7514d39c9 100644
--- a/Include/Python.h
+++ b/Include/Python.h
@@ -53,6 +53,15 @@
#include "pyport.h"
#include "pymacro.h"
+/* A convenient way for code to know if clang's memory sanitizer is enabled. */
+#if defined(__has_feature)
+# if __has_feature(memory_sanitizer)
+# if !defined(MEMORY_SANITIZER)
+# define MEMORY_SANITIZER
+# endif
+# endif
+#endif
+
#include "pyatomic.h"
/* Debug-mode build with pymalloc implies PYMALLOC_DEBUG.