Are valgrind "uninitialized value" warnings false positives in ATLAS multithreaded BLAS routines? Are valgrind "uninitialized value" warnings false positives in ATLAS multithreaded BLAS routines? c c

Are valgrind "uninitialized value" warnings false positives in ATLAS multithreaded BLAS routines?


is valgrind giving me false positive errors?

Looks like no.

Instead of running valgrind with --leak-check=yes you should have run it with --track-origins=yes to see where uninitialised values come from as suggested by valgrind at the end of the output. Here is what I've got with --track-origins=yes:

[ ~]$ valgrind --track-origins=yes ./a.out ==17533== Memcheck, a memory error detector==17533== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.==17533== Using Valgrind-3.12.0 and LibVEX; rerun with -h for copyright info==17533== Command: ./a.out==17533== ==17533== Conditional jump or move depends on uninitialised value(s)==17533==    at 0x4F4362B: ??? (in /usr/lib64/atlas/libtatlas.so.3.10)==17533==    by 0x4EB99E3: ATL_dgetf2 (in /usr/lib64/atlas/libtatlas.so.3.10)==17533==    by 0x4EC42BF: ATL_dtgetrfC (in /usr/lib64/atlas/libtatlas.so.3.10)==17533==    by 0x4EC42BF: ATL_dtgetrfC (in /usr/lib64/atlas/libtatlas.so.3.10)==17533==    by 0x4EC42BF: ATL_dtgetrfC (in /usr/lib64/atlas/libtatlas.so.3.10)==17533==    by 0x4EC42BF: ATL_dtgetrfC (in /usr/lib64/atlas/libtatlas.so.3.10)==17533==    by 0x4F06538: atl_f77wrap_dgetrf_ (in /usr/lib64/atlas/libtatlas.so.3.10)==17533==    by 0x4F07416: dgetrf_ (in /usr/lib64/atlas/libtatlas.so.3.10)==17533==    by 0x400A29: main (fermi.c:50)==17533==  Uninitialised value was created by a heap allocation==17533==    at 0x4C2DB9D: malloc (vg_replace_malloc.c:299)==17533==    by 0x40080B: main (fermi.c:22)

So the source of uninitialised values is this line of code:

temp = malloc(dim*dim*sizeof(double));

It is then used to initialise m1 which is passed to dgetrf_() on line 50.

I'm not familiar with ATLAS library but I guess you should somehow initialise temp variable. For example zero initialising temp with calloc resolves all these valgrind errors:

temp = calloc(dim*dim,sizeof(double));