diff options
author | Gregory P. Smith <greg@krypto.org> | 2018-11-12 20:07:14 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-12 20:07:14 (GMT) |
commit | 1584a0081500d35dc93ff88e5836df35faf3e3e2 (patch) | |
tree | 986afdd14c17e1678359e28513bd13452152c59f /Python/bootstrap_hash.c | |
parent | a9655b7f71b8976c369160ef362d0e706cfcd8c9 (diff) | |
download | cpython-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 'Python/bootstrap_hash.c')
-rw-r--r-- | Python/bootstrap_hash.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Python/bootstrap_hash.c b/Python/bootstrap_hash.c index 7b187f1..1b8f9d9 100644 --- a/Python/bootstrap_hash.c +++ b/Python/bootstrap_hash.c @@ -20,6 +20,10 @@ # endif #endif +#ifdef MEMORY_SANITIZER +# include <sanitizer/msan_interface.h> +#endif + #ifdef Py_DEBUG int _Py_HashSecret_Initialized = 0; #else @@ -143,6 +147,11 @@ py_getrandom(void *buffer, Py_ssize_t size, int blocking, int raise) else { n = syscall(SYS_getrandom, dest, n, flags); } +# ifdef MEMORY_SANITIZER + if (n > 0) { + __msan_unpoison(dest, n); + } +# endif #endif if (n < 0) { |