shithub: dav1d

Download patch

ref: ef990c9d82f7fa2f6c7c39c53e2c3d6cbc5b0d6c
parent: 87d5dc8e3bd6863391acdbcac845796bc17f284c
author: Janne Grunau <[email protected]>
date: Fri Apr 10 14:55:04 EDT 2020

memory sanitizer: mask all CPU flags

Memory sanitizer depends on compiler instrumentation which makes it
inherently incompatible with asm DSP functions. Refs #336

--- a/include/common/attributes.h
+++ b/include/common/attributes.h
@@ -159,4 +159,8 @@
 }
 #endif /* !_MSC_VER */
 
+#ifndef __has_feature
+#define __has_feature(x) 0
+#endif
+
 #endif /* DAV1D_COMMON_ATTRIBUTES_H */
--- a/src/cpu.c
+++ b/src/cpu.c
@@ -31,7 +31,11 @@
 #include "src/cpu.h"
 
 static unsigned flags = 0;
-#if ARCH_X86
+
+#if __has_feature(memory_sanitizer)
+// memory sanitizer is inherently incompatible with asm
+static unsigned flags_mask = 0;
+#elif ARCH_X86
 /* Disable AVX-512 by default for the time being */
 static unsigned flags_mask = ~DAV1D_X86_CPU_FLAG_AVX512ICL;
 #else
--- a/src/decode.c
+++ b/src/decode.c
@@ -1998,7 +1998,6 @@
     return 0;
 }
 
-#if defined(__has_feature)
 #if __has_feature(memory_sanitizer)
 
 #include <sanitizer/msan_interface.h>
@@ -2051,7 +2050,6 @@
 #define decode_b checked_decode_b
 
 #endif /* defined(__has_feature) */
-#endif /* __has_feature(memory_sanitizer) */
 
 static int decode_sb(Dav1dTileContext *const t, const enum BlockLevel bl,
                      const EdgeNode *const node)
--- a/tests/libfuzzer/dav1d_fuzzer.c
+++ b/tests/libfuzzer/dav1d_fuzzer.c
@@ -69,13 +69,6 @@
 
     dav1d_version();
 
-    // memory sanitizer is inherently incompatible with asm
-#if defined(__has_feature)
-  #if __has_feature(memory_sanitizer)
-    dav1d_set_cpu_flags_mask(0);
-  #endif
-#endif
-
     if (size < 32) goto end;
 #ifdef DAV1D_ALLOC_FAIL
     unsigned h = djb_xor(ptr, 32);