failure with Clang's memory sanitizer: use-of-uninitialized-value

Marc Glisse marc.glisse at inria.fr
Thu Mar 28 21:31:37 UTC 2019


On Thu, 28 Mar 2019, Niels Möller wrote:

> Vincent Lefevre <vincent at vinc17.net> writes:
>
>> On my Debian/unstable x86_64 machine (with GMP 6.1.2):
>>
>> #include <gmp.h>
>>
>> int main (void)
>> {
>>   mpz_t z;
>>
>>   mpz_init (z);
>>   mpz_set_ui (z, 1);
>>   mpz_dump (z);
>>   mpz_clear (z);
>>
>>   return 0;
>> }
>>
>> compiled with: clang-7 -fsanitize=memory -o tst tst.c -lgmp
>
> Is -fsanitize=memory reliable when the C compiler doesn't get to see all
> the source files? Do you get the same result of you recompile gmp using
> CC='clang-7 -fsanitize=memory'? If you also recompile with
> --disable-assembly?

Just recompiling GMP with CC='clang-7 -fsanitize=memory' (and 
--disable-shared) gives the more specific

==28897==WARNING: MemorySanitizer: use-of-uninitialized-value
     #0 0x498856 in mpn_bc_get_str /tmp/g/mpn/get_str.c:239:7
     #1 0x497843 in __gmpn_get_str /tmp/g/mpn/get_str.c:430:12
     #2 0x496e83 in __gmpz_get_str /home/glisse/repos/gmp/mpz/get_str.c:96:14
     #3 0x496af7 in __gmpz_dump /home/glisse/repos/gmp/mpz/dump.c:45:9
     #4 0x4969ec in main /tmp/b.c:9:3
     #5 0x7f743f2ef09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
     #6 0x41e2a9 in _start (/tmp/a.out+0x41e2a9)

SUMMARY: MemorySanitizer: use-of-uninitialized-value 
/tmp/g/mpn/get_str.c:239:7 in mpn_bc_get_str
Exiting

while adding --disable-assembly lets the program run without error.

-- 
Marc Glisse


More information about the gmp-bugs mailing list