glenvt18 / libdvbcsa

GNU General Public License v2.0
11 stars 17 forks source link

valgrind complains about use of uninitialised value in bitslice #2

Open quarium opened 7 years ago

quarium commented 7 years ago
$ valgrind test/benchbitslice
==27466== Memcheck, a memory error detector
==27466== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==27466== Using Valgrind-3.12.0.SVN and LibVEX; rerun with -h for copyright info
==27466== Command: /home/quark/libdvbcsa-glenvt18/test/.libs/benchbitslice
==27466== 
* DVBCSA bench *
 - Generating batch with 128 randomly sized packets

 - decrypting 4096 TS packets
==27466== Use of uninitialised value of size 8
==27466==    at 0x4E3BC38: dvbcsa_bs_block_decrypt_batch (in /home/quark/libdvbcsa-glenvt18/src/.libs/libdvbcsa.so.1.0.1)
==27466==    by 0x4E3B7EB: dvbcsa_bs_decrypt (in /home/quark/libdvbcsa-glenvt18/src/.libs/libdvbcsa.so.1.0.1)
==27466==    by 0x108E97: main (in /home/quark/libdvbcsa-glenvt18/test/.libs/benchbitslice)
==27466== 
==27466== Use of uninitialised value of size 8
==27466==    at 0x4E3BC8E: dvbcsa_bs_block_decrypt_batch (in /home/quark/libdvbcsa-glenvt18/src/.libs/libdvbcsa.so.1.0.1)
==27466==    by 0x4E3B7EB: dvbcsa_bs_decrypt (in /home/quark/libdvbcsa-glenvt18/src/.libs/libdvbcsa.so.1.0.1)
==27466==    by 0x108E97: main (in /home/quark/libdvbcsa-glenvt18/test/.libs/benchbitslice)
==27466== 
==27466== Use of uninitialised value of size 8
==27466==    at 0x4E3BC21: dvbcsa_bs_block_decrypt_batch (in /home/quark/libdvbcsa-glenvt18/src/.libs/libdvbcsa.so.1.0.1)
==27466==    by 0x4E3B7EB: dvbcsa_bs_decrypt (in /home/quark/libdvbcsa-glenvt18/src/.libs/libdvbcsa.so.1.0.1)
==27466==    by 0x108E97: main (in /home/quark/libdvbcsa-glenvt18/test/.libs/benchbitslice)
==27466== 
==27466== Use of uninitialised value of size 8
==27466==    at 0x4E3BC44: dvbcsa_bs_block_decrypt_batch (in /home/quark/libdvbcsa-glenvt18/src/.libs/libdvbcsa.so.1.0.1)
==27466==    by 0x4E3B7EB: dvbcsa_bs_decrypt (in /home/quark/libdvbcsa-glenvt18/src/.libs/libdvbcsa.so.1.0.1)
==27466==    by 0x108E97: main (in /home/quark/libdvbcsa-glenvt18/test/.libs/benchbitslice)
==27466== 
...
glenvt18 commented 7 years ago

@quarium Could you provide some details: target platform, toolchain, build options, valgrind settings etc. I couldn't reproduce it on x86_64 with gcc 5.4 using either sse2 or ssse3.

quarium commented 7 years ago

Yes sorry, x86_64 with gcc (Debian 6.3.0-18) 6.3.0 20170516, valgrind-3.12.0.SVN and ssse3.

glenvt18 commented 7 years ago

BTW Could you try d11b0b2

quarium commented 7 years ago

No more warnings with this commit

glenvt18 commented 7 years ago

OK. In fact, libdvbcsa can actually process uninitialized data if, for example, packet size is less than 184, or the batch is less than 128 packets (try test/testbitslice). In this case it gets garbage, processes garbage but doesn't copy the garbage to the output buffers. Initializing the internal buffer with memset() will have (a very small) performance impact. I have to run benchmarks on weakest targets (ARM) to see if passing valgrind checks worth the performance drop. So, it's not really an issue.

Thanks for testing.