Work around valgrind/MSan SIMD false positives
Referring to https://sourceforge.net/p/libjpeg-turbo/bugs/48, https://sourceforge.net/p/libjpeg-turbo/bugs/82, #15, #238, #253, and #619, valgrind and MSan have failed to properly detect data initialization by libjpeg-turbo's x86 SIMD extensions for the entire 14 years that libjpeg-turbo has been a project, resulting in false positives unless libjpeg-turbo is built with WITH_SIMD=0 or run with JSIMD_FORCENONE=1. This commit introduces a new C preprocessor macro (ZERO_BUFFERS) that, if set, causes libjpeg-turbo to zero certain buffers in order to work around the specific valgrind/MSan test failures caused by the aforementioned false positives. This allows us to more closely approximate the production configuration of libjpeg-turbo when testing with valgrind or MSan. Closes #781
This commit is contained in:
10
jcphuff.c
10
jcphuff.c
@@ -650,6 +650,11 @@ encode_mcu_AC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
size_t bits[8 / SIZEOF_SIZE_T];
|
||||
int max_coef_bits = cinfo->data_precision + 2;
|
||||
|
||||
#ifdef ZERO_BUFFERS
|
||||
memset(values_unaligned, 0, sizeof(values_unaligned));
|
||||
memset(bits, 0, sizeof(bits));
|
||||
#endif
|
||||
|
||||
entropy->next_output_byte = cinfo->dest->next_output_byte;
|
||||
entropy->free_in_buffer = cinfo->dest->free_in_buffer;
|
||||
|
||||
@@ -915,6 +920,11 @@ encode_mcu_AC_refine(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
size_t zerobits, signbits;
|
||||
size_t bits[16 / SIZEOF_SIZE_T];
|
||||
|
||||
#ifdef ZERO_BUFFERS
|
||||
memset(absvalues_unaligned, 0, sizeof(absvalues_unaligned));
|
||||
memset(bits, 0, sizeof(bits));
|
||||
#endif
|
||||
|
||||
entropy->next_output_byte = cinfo->dest->next_output_byte;
|
||||
entropy->free_in_buffer = cinfo->dest->free_in_buffer;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user