mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
bpo-35214: MSan workarounds for socket, time, and test_faulthandler. (GH-11375)
Add Clang Memory Sanitizer build instrumentation to work around false positives from the socket and time modules as well as skipping a couple test_faulthandler tests.
This commit is contained in:
parent
387512c7ec
commit
b474e6774d
4 changed files with 38 additions and 0 deletions
|
@ -102,6 +102,10 @@ Local naming conventions:
|
|||
#include "Python.h"
|
||||
#include "structmember.h"
|
||||
|
||||
#ifdef _Py_MEMORY_SANITIZER
|
||||
# include <sanitizer/msan_interface.h>
|
||||
#endif
|
||||
|
||||
/* Socket object documentation */
|
||||
PyDoc_STRVAR(sock_doc,
|
||||
"socket(family=AF_INET, type=SOCK_STREAM, proto=0) -> socket object\n\
|
||||
|
@ -6571,7 +6575,23 @@ socket_if_nameindex(PyObject *self, PyObject *arg)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef _Py_MEMORY_SANITIZER
|
||||
__msan_unpoison(ni, sizeof(ni));
|
||||
__msan_unpoison(&ni[0], sizeof(ni[0]));
|
||||
#endif
|
||||
for (i = 0; ni[i].if_index != 0 && i < INT_MAX; i++) {
|
||||
#ifdef _Py_MEMORY_SANITIZER
|
||||
/* This one isn't the end sentinel, the next one must exist. */
|
||||
__msan_unpoison(&ni[i+1], sizeof(ni[0]));
|
||||
/* Otherwise Py_BuildValue internals are flagged by MSan when
|
||||
they access the not-msan-tracked if_name string data. */
|
||||
{
|
||||
char *to_sanitize = ni[i].if_name;
|
||||
do {
|
||||
__msan_unpoison(to_sanitize, 1);
|
||||
} while (*to_sanitize++ != '\0');
|
||||
}
|
||||
#endif
|
||||
PyObject *ni_tuple = Py_BuildValue("IO&",
|
||||
ni[i].if_index, PyUnicode_DecodeFSDefault, ni[i].if_name);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue