summaryrefslogtreecommitdiffstats
path: root/Include/Python.h
diff options
context:
space:
mode:
authorGregory P. Smith <greg@krypto.org>2018-11-12 20:07:14 (GMT)
committerGitHub <noreply@github.com>2018-11-12 20:07:14 (GMT)
commit1584a0081500d35dc93ff88e5836df35faf3e3e2 (patch)
tree986afdd14c17e1678359e28513bd13452152c59f /Include/Python.h
parenta9655b7f71b8976c369160ef362d0e706cfcd8c9 (diff)
downloadcpython-1584a0081500d35dc93ff88e5836df35faf3e3e2.zip
cpython-1584a0081500d35dc93ff88e5836df35faf3e3e2.tar.gz
cpython-1584a0081500d35dc93ff88e5836df35faf3e3e2.tar.bz2
bpo-35214: Initial clang MemorySanitizer support (GH-10479)
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.
Diffstat (limited to 'Include/Python.h')
-rw-r--r--Include/Python.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/Include/Python.h b/Include/Python.h
index cf87a5c..bece208 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
+
/* Debug-mode build with pymalloc implies PYMALLOC_DEBUG.
* PYMALLOC_DEBUG is in error if pymalloc is not in use.
*/