02-sanitizer.patch 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. Memory sanitizer does not handle assembly code well and may generate false
  2. positives. libjpeg-turbo readme suggests to disable SIMD extensions at all when
  3. running it with sanitizers. We do not do this, but disable only some SIMD
  4. routines that cause problems with our tests.
  5. For more info see:
  6. * https://st.yandex-team.ru/CV-219
  7. * https://st.yandex-team.ru/DEVTOOLSSUPPORT-728
  8. * https://github.com/google/sanitizers/issues/192
  9. * https://github.com/libjpeg-turbo/libjpeg-turbo#memory-debugger-pitfalls
  10. * http://clang.llvm.org/docs/MemorySanitizer.html#handling-external-code
  11. --- b/jinclude.h
  12. +++ a/jinclude.h
  13. @@ -130,6 +130,10 @@
  14. #endif /* _WIN32 */
  15. #endif /* NO_PUTENV */
  16. +
  17. +#ifdef WITH_SANITIZER
  18. +# define malloc(sz) calloc((sz), 1)
  19. +#endif
  20. #endif /* JINCLUDE_H */
  21. --- b/simd/x86_64/jsimd.c
  22. +++ a/simd/x86_64/jsimd.c
  23. @@ -116,6 +116,7 @@ jsimd_can_ycc_rgb(void)
  24. {
  25. init_simd();
  26. +#ifndef WITH_SANITIZER
  27. /* The code is optimised for these values only */
  28. if (BITS_IN_JSAMPLE != 8)
  29. return 0;
  30. @@ -130,6 +131,7 @@ jsimd_can_ycc_rgb(void)
  31. if ((simd_support & JSIMD_SSE2) &&
  32. IS_ALIGNED_SSE(jconst_ycc_rgb_convert_sse2))
  33. return 1;
  34. +#endif
  35. return 0;
  36. }
  37. @@ -997,6 +999,7 @@ jsimd_can_huff_encode_one_block(void)
  38. {
  39. init_simd();
  40. +#ifndef WITH_SANITIZER
  41. if (DCTSIZE != 8)
  42. return 0;
  43. if (sizeof(JCOEF) != 2)
  44. @@ -1005,6 +1008,7 @@ jsimd_can_huff_encode_one_block(void)
  45. if ((simd_support & JSIMD_SSE2) && simd_huffman &&
  46. IS_ALIGNED_SSE(jconst_huff_encode_one_block))
  47. return 1;
  48. +#endif
  49. return 0;
  50. }
  51. @@ -1023,6 +1027,7 @@ jsimd_can_encode_mcu_AC_first_prepare(void)
  52. {
  53. init_simd();
  54. +#ifndef WITH_SANITIZER
  55. if (DCTSIZE != 8)
  56. return 0;
  57. if (sizeof(JCOEF) != 2)
  58. @@ -1029,6 +1034,7 @@ jsimd_can_encode_mcu_AC_first_prepare(void)
  59. return 0;
  60. if (simd_support & JSIMD_SSE2)
  61. return 1;
  62. +#endif
  63. return 0;
  64. }
  65. @@ -1047,6 +1053,7 @@ jsimd_can_encode_mcu_AC_refine_prepare(void)
  66. {
  67. init_simd();
  68. +#ifndef WITH_SANITIZER
  69. if (DCTSIZE != 8)
  70. return 0;
  71. if (sizeof(JCOEF) != 2)
  72. @@ -1053,6 +1060,7 @@ jsimd_can_encode_mcu_AC_refine_prepare(void)
  73. return 0;
  74. if (simd_support & JSIMD_SSE2)
  75. return 1;
  76. +#endif
  77. return 0;
  78. }