diff options
author | Augie Fackler <raf@durin42.com> | 2018-12-03 18:34:29 -0500 |
---|---|---|
committer | Oliver Chang <oliverchang@users.noreply.github.com> | 2018-12-04 10:34:29 +1100 |
commit | 7bd1239ab33f54955601f9d90da95246b7f82871 (patch) | |
tree | a70e1a7d1c830a536fd0a94ca51f312f00bfed84 /projects/mercurial | |
parent | 832d2c220d8dd6a62937e52952a7438344edf896 (diff) | |
download | oss-fuzz-7bd1239ab33f54955601f9d90da95246b7f82871.tar.gz |
mercurial: set up infrastructure required for fixing msan build (#1999)
The cpython patch is derived from the work done in
https://bugs.python.org/issue35214 by Greg Smith. It's required to
unblock msan builds on Python 2.7. Once upstream cpython 3 is fixed to
support msan builds, we should probably move to fuzzing under Python 3
instead of Python 2.
I'll wait to enable msan builds until the associated fixes in hg core
land, since I'm not sure when that will happen.
Diffstat (limited to 'projects/mercurial')
-rwxr-xr-x | projects/mercurial/build.sh | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/projects/mercurial/build.sh b/projects/mercurial/build.sh index c21c7bd69..58d0670d9 100755 --- a/projects/mercurial/build.sh +++ b/projects/mercurial/build.sh @@ -15,5 +15,39 @@ # ################################################################################ +pushd /Python-2.7.15/ +ls +patch -p1 <<'EOF' +Index: v2_7_unstable/Python/pymath.c +=================================================================== +--- v2_7_unstable.orig/Python/pymath.c ++++ v2_7_unstable/Python/pymath.c +@@ -18,6 +18,7 @@ double _Py_force_double(double x) + /* inline assembly for getting and setting the 387 FPU control word on + gcc/x86 */ + ++__attribute__((no_sanitize_memory)) + unsigned short _Py_get_387controlword(void) { + unsigned short cw; + __asm__ __volatile__ ("fnstcw %0" : "=m" (cw)); +Index: v2_7_unstable/Modules/_ctypes/callproc.c +=================================================================== +--- v2_7_unstable.orig/Modules/_ctypes/callproc.c ++++ v2_7_unstable/Modules/_ctypes/callproc.c +@@ -1166,6 +1166,10 @@ PyObject *_ctypes_callproc(PPROC pProc, + + rtype = _ctypes_get_ffi_type(restype); + resbuf = alloca(max(rtype->size, sizeof(ffi_arg))); ++ /* ffi_call actually initializes resbuf, but from asm, which ++ * MemorySanitizer can't detect. Avoid false positives from MSan. */ ++ if (resbuf != NULL) ++ memset(resbuf, 0, max(rtype->size, sizeof(ffi_arg))); + + avalues = (void **)alloca(sizeof(void *) * argcount); + atypes = (ffi_type **)alloca(sizeof(ffi_type *) * argcount); +EOF +popd + cd contrib/fuzz +export PYLDFLAGS=$(echo $CFLAGS | xargs -n 1 echo | egrep -- '-fsanitize=(memory|address)') make oss-fuzz |