[petsc-dev] MPICH from --download-mpich reports inconsistent allocs/frees with valgrind

Patrick Sanan patrick.sanan at gmail.com
Mon Jul 22 04:12:35 CDT 2019

It was pointed out to me that valgrind memcheck reports inconsistent heap
usage information when running PETSc examples. All blocks are reported
freed, yet the number of allocations and frees are different. My guess as
to what's going on is that this is an MPICH issue, as I can reproduce the
behavior with a minimal MPI program.

>From the PETSc perspective, is this a known issue?  I'm wondering if this
inconsistency was always there, whether it's worth looking into more, etc.

Here's a 1-liner to reproduce, using a PETSc master build with
--download-mpich (though note that this doesn't use anything from PETSc
except the MPICH it builds for you).

     printf "#include<mpi.h>\nint main(int a,char
**b){MPI_Init(&a,&b);MPI_Finalize();}" > t.c &&
$PETSC_DIR/$PETSC_ARCH/bin/mpicc t.c && valgrind ./a.out

==14242== Memcheck, a memory error detector
==14242== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==14242== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==14242== Command: ./a.out
==14242== HEAP SUMMARY:
==14242==     in use at exit: 0 bytes in 0 blocks
==14242==   total heap usage: *1,979 allocs, 1,974 frees*, 4,720,483 bytes
==14242== All heap blocks were freed -- no leaks are possible
==14242== For counts of detected and suppressed errors, rerun with: -v
==14242== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20190722/2fd0586b/attachment.html>

More information about the petsc-dev mailing list