diff options
author | Gregory P. Smith <greg@krypto.org> | 2018-11-12 16:10:21 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-12 16:10:21 -0800 |
commit | 3b5b1c0931cd32253bbf2f3bd74e90ff821e026e (patch) | |
tree | fde2e9f1df686bb53ba4711232e1bc72c51beae9 /Modules/_posixsubprocess.c | |
parent | 9a7ba8c68bd40901917d3f53261cbb7561b5bdf8 (diff) | |
download | cpython-git-3b5b1c0931cd32253bbf2f3bd74e90ff821e026e.tar.gz |
[3.6] bpo-35214: Initial clang MemorySanitizer support (GH-10479) (GH-10493)
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)
Contributed by Gregory P. Smith [Google LLC]
Also includes a whitespace fix from make patchcheck to _posixsubprocess.c - unrelated to the main change that makes the CI happy so I'm just doing it now rather than creating a separate PR.
Diffstat (limited to 'Modules/_posixsubprocess.c')
-rw-r--r-- | Modules/_posixsubprocess.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c index fe0e554618..fe519dea9c 100644 --- a/Modules/_posixsubprocess.c +++ b/Modules/_posixsubprocess.c @@ -21,6 +21,10 @@ #include <dirent.h> #endif +#ifdef MEMORY_SANITIZER +# include <sanitizer/msan_interface.h> +#endif + #if defined(__ANDROID__) && __ANDROID_API__ < 21 && !defined(SYS_getdents64) # include <sys/linux-syscalls.h> # define SYS_getdents64 __NR_getdents64 @@ -287,6 +291,9 @@ _close_open_fds_safe(int start_fd, PyObject* py_fds_to_keep) sizeof(buffer))) > 0) { struct linux_dirent64 *entry; int offset; +#ifdef MEMORY_SANITIZER + __msan_unpoison(buffer, bytes); +#endif for (offset = 0; offset < bytes; offset += entry->d_reclen) { int fd; entry = (struct linux_dirent64 *)(buffer + offset); @@ -791,11 +798,11 @@ static PyMethodDef module_methods[] = { static struct PyModuleDef _posixsubprocessmodule = { - PyModuleDef_HEAD_INIT, - "_posixsubprocess", - module_doc, - -1, /* No memory is needed. */ - module_methods, + PyModuleDef_HEAD_INIT, + "_posixsubprocess", + module_doc, + -1, /* No memory is needed. */ + module_methods, }; PyMODINIT_FUNC |