Skip to content

Commit efcf08d

Browse files
authored
[3.7] bpo-35214: Annotate posix calls for clang MSan. (GH-11389) (GH-11391)
It doesn't know the details of a few less common libc functions.. (cherry picked from commit 1d300ce) Co-authored-by: Gregory P. Smith <[email protected]> [Google]
1 parent 75bf2b1 commit efcf08d

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
clang Memory Sanitizer build instrumentation was added to work around false
2-
positives from socket, time, test_io, and test_faulthandler.
2+
positives from posix, socket, time, test_io, and test_faulthandler.

Modules/posixmodule.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,10 @@ static int win32_can_symlink = 0;
393393
#define HAVE_STRUCT_STAT_ST_FSTYPE 1
394394
#endif
395395

396+
#ifdef _Py_MEMORY_SANITIZER
397+
# include <sanitizer/msan_interface.h>
398+
#endif
399+
396400
#ifdef HAVE_FORK
397401
static void
398402
run_at_forkers(PyObject *lst, int reverse)
@@ -5689,6 +5693,9 @@ os_sched_rr_get_interval_impl(PyObject *module, pid_t pid)
56895693
posix_error();
56905694
return -1.0;
56915695
}
5696+
#ifdef _Py_MEMORY_SANITIZER
5697+
__msan_unpoison(&interval, sizeof(interval));
5698+
#endif
56925699
return (double)interval.tv_sec + 1e-9*interval.tv_nsec;
56935700
}
56945701
#endif /* HAVE_SCHED_RR_GET_INTERVAL */
@@ -6155,6 +6162,12 @@ posix_getgrouplist(PyObject *self, PyObject *args)
61556162
return posix_error();
61566163
}
61576164

6165+
#ifdef _Py_MEMORY_SANITIZER
6166+
/* Clang memory sanitizer libc intercepts don't know getgrouplist. */
6167+
__msan_unpoison(&ngroups, sizeof(ngroups));
6168+
__msan_unpoison(groups, ngroups*sizeof(*groups));
6169+
#endif
6170+
61586171
list = PyList_New(ngroups);
61596172
if (list == NULL) {
61606173
PyMem_Del(groups);

0 commit comments

Comments
 (0)