From 17780995b127644bb3031862e551d7d592eabe33 Mon Sep 17 00:00:00 2001 From: Rik Prohaska Date: Mon, 9 Nov 2015 07:10:26 -0500 Subject: [PATCH] compress-test fails with valgrind due to conditional jump depended on an uninitialized value. the uninitialized value occurs because the lzma encoder object is not fully initialized by its constructor. the bug fix is to initialize the variables in the encoder's constructor. the test is to run 'make check' on the third party xz software. the alternative fix is to add valgrind suppressions for the errors. here is the valgrind report: ==2368== Conditional jump or move depends on uninitialised value(s) ==2368== at 0x4F5F21D: lz_encoder_prepare (lz_encoder.c:222) ==2368== by 0x4F5F8DA: lzma_lz_encoder_init (lz_encoder.c:516) ==2368== by 0x4F5F0CE: lzma_raw_coder_init (filter_common.c:212) ==2368== by 0x4F52FF1: block_encode_normal (block_buffer_encoder.c:192) ==2368== by 0x4F52FF1: lzma_block_buffer_encode (block_buffer_encoder.c:258) ==2368== by 0x4F4F63D: lzma_stream_buffer_encode (stream_buffer_encoder.c:93) ==2368== by 0x4F4F4A3: lzma_easy_buffer_encode (easy_buffer_encoder.c:27) ==2368== by 0x4F046E9: toku_compress(toku_compression_method, unsigned char*, unsigned long*, unsigned char const*, unsigned long) (compress.cc:141) ==2368== by 0x4022A7: test_compress_buf_method(unsigned char*, int, toku_compression_method) (compress-test.cc:54) ==2368== by 0x4023B4: test_compress_i(int, toku_compression_method, unsigned long*, unsigned long*) (compress-test.cc:66) ==2368== by 0x4024E8: test_compress(toku_compression_method, unsigned long*, unsigned long*) (compress-test.cc:83) ==2368== by 0x402841: test_compress_methods() (compress-test.cc:123) ==2368== by 0x402A13: test_main(int, char const**) (compress-test.cc:142) ==2368== by 0x4021DB: main (test.h:346) ==2368== ==2368== Conditional jump or move depends on uninitialised value(s) ==2368== at 0x4F5F32D: lz_encoder_prepare (lz_encoder.c:344) ==2368== by 0x4F5F8DA: lzma_lz_encoder_init (lz_encoder.c:516) ==2368== by 0x4F5F0CE: lzma_raw_coder_init (filter_common.c:212) ==2368== by 0x4F52FF1: block_encode_normal (block_buffer_encoder.c:192) ==2368== by 0x4F52FF1: lzma_block_buffer_encode (block_buffer_encoder.c:258) ==2368== by 0x4F4F63D: lzma_stream_buffer_encode (stream_buffer_encoder.c:93) ==2368== by 0x4F4F4A3: lzma_easy_buffer_encode (easy_buffer_encoder.c:27) ==2368== by 0x4F046E9: toku_compress(toku_compression_method, unsigned char*, unsigned long*, unsigned char const*, unsigned long) (compress.cc:141) ==2368== by 0x4022A7: test_compress_buf_method(unsigned char*, int, toku_compression_method) (compress-test.cc:54) ==2368== by 0x4023B4: test_compress_i(int, toku_compression_method, unsigned long*, unsigned long*) (compress-test.cc:66) ==2368== by 0x4024E8: test_compress(toku_compression_method, unsigned long*, unsigned long*) (compress-test.cc:83) ==2368== by 0x402841: test_compress_methods() (compress-test.cc:123) ==2368== by 0x402A13: test_main(int, char const**) (compress-test.cc:142) ==2368== by 0x4021DB: main (test.h:346) ==2368== --- third_party/xz-4.999.9beta/src/liblzma/lz/lz_encoder.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/third_party/xz-4.999.9beta/src/liblzma/lz/lz_encoder.c b/third_party/xz-4.999.9beta/src/liblzma/lz/lz_encoder.c index c4154f598..c7c874e83 100644 --- a/third_party/xz-4.999.9beta/src/liblzma/lz/lz_encoder.c +++ b/third_party/xz-4.999.9beta/src/liblzma/lz/lz_encoder.c @@ -501,7 +501,10 @@ lzma_lz_encoder_init(lzma_next_coder *next, lzma_allocator *allocator, next->coder->lz.end = NULL; next->coder->mf.buffer = NULL; + next->coder->mf.size = 0; next->coder->mf.hash = NULL; + next->coder->mf.hash_size_sum = 0; + next->coder->mf.sons_count = 0; next->coder->next = LZMA_NEXT_CODER_INIT; }