aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/libjpeg-turbo/patches/02-sanitizer.patch
blob: b219fe93d239077bb4f9e57eaff30b009bd46632 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
Memory sanitizer does not handle assembly code well and may generate false
positives. libjpeg-turbo readme suggests to disable SIMD extensions at all when
running it with sanitizers. We do not do this, but disable only some SIMD
routines that cause problems with our tests.
For more info see:
* https://st.yandex-team.ru/CV-219
* https://st.yandex-team.ru/DEVTOOLSSUPPORT-728
* https://github.com/google/sanitizers/issues/192
* https://github.com/libjpeg-turbo/libjpeg-turbo#memory-debugger-pitfalls
* http://clang.llvm.org/docs/MemorySanitizer.html#handling-external-code

--- b/jinclude.h
+++ a/jinclude.h
@@ -130,6 +130,10 @@
 #endif /* _WIN32 */
 
 #endif /* NO_PUTENV */
+ 
+#ifdef WITH_SANITIZER
+#  define malloc(sz) calloc((sz), 1)
+#endif


 #endif /* JINCLUDE_H */
--- b/simd/x86_64/jsimd.c
+++ a/simd/x86_64/jsimd.c
@@ -116,6 +116,7 @@ jsimd_can_ycc_rgb(void)
 {
   init_simd();

+#ifndef WITH_SANITIZER
   /* The code is optimised for these values only */
   if (BITS_IN_JSAMPLE != 8)
     return 0;
@@ -130,6 +131,7 @@ jsimd_can_ycc_rgb(void)
   if ((simd_support & JSIMD_SSE2) &&
       IS_ALIGNED_SSE(jconst_ycc_rgb_convert_sse2))
     return 1;
+#endif

   return 0;
 }
@@ -997,6 +999,7 @@ jsimd_can_huff_encode_one_block(void)
 {
   init_simd();

+#ifndef WITH_SANITIZER
   if (DCTSIZE != 8)
     return 0;
   if (sizeof(JCOEF) != 2)
@@ -1005,6 +1008,7 @@ jsimd_can_huff_encode_one_block(void)
   if ((simd_support & JSIMD_SSE2) && simd_huffman &&
       IS_ALIGNED_SSE(jconst_huff_encode_one_block))
     return 1;
+#endif

   return 0;
 }
@@ -1023,6 +1027,7 @@ jsimd_can_encode_mcu_AC_first_prepare(void)
 {
   init_simd();

+#ifndef WITH_SANITIZER
   if (DCTSIZE != 8)
     return 0;
   if (sizeof(JCOEF) != 2)
@@ -1029,6 +1034,7 @@ jsimd_can_encode_mcu_AC_first_prepare(void)
     return 0;
   if (simd_support & JSIMD_SSE2)
     return 1;
+#endif

   return 0;
 }
@@ -1047,6 +1053,7 @@ jsimd_can_encode_mcu_AC_refine_prepare(void)
 {
   init_simd();

+#ifndef WITH_SANITIZER
   if (DCTSIZE != 8)
     return 0;
   if (sizeof(JCOEF) != 2)
@@ -1053,6 +1060,7 @@ jsimd_can_encode_mcu_AC_refine_prepare(void)
     return 0;
   if (simd_support & JSIMD_SSE2)
     return 1;
+#endif

   return 0;
 }