memory leak in pnetcdf?

Ed Hartnett edwardjameshartnett at gmail.com
Fri Mar 18 19:37:30 CDT 2016


OK, I'll give it a try tomorrow!

Thanks,
Ed

On Fri, Mar 18, 2016 at 6:27 PM, Wei-keng Liao <wkliao at eecs.northwestern.edu
> wrote:

> Hi, Ed
>
> Thanks for reporting the problem.
>
> I can reproduce the same valgrind output when using 1.6.1, but not 1.7.0.
> The source locations pointed out by valgrind does not seem to be the cause
> as
> the files are basically the same between the two PnetCDF versions.
>
> I suggest to use 1.7.0, because some bugs have been fixed since 1.6.1 that
> may
> also fix the memory leak by accident.
>
> Wei-keng
>
> On Mar 18, 2016, at 12:30 PM, Ed Hartnett wrote:
>
> > Howdy pnetcdf folk!
> >
> > While working on the PIO library I found what appears to be a memory
> leak in pnetcdf.
> >
> > I am using version 1.6.1 of the parallel-netcdf library. The following
> simple program results in a 5-byte leak, as indicated by the valgrind
> output which follows the code listing.
> >
> > A little experimentation shows that it is the attribute name which is
> being copied to a new memory location and then never freed.
> >
> > Thanks,
> > Ed
> >
> >
> > #include <pnetcdf.h>
> >
> > int
> > main(int argc, char **argv)
> > {
> >     int ncid, ret;
> >
> >     /* Initialize MPI. */
> >     if ((ret = MPI_Init(&argc, &argv)))
> >       return ret;
> >
> >     /* Create the netCDF output file. */
> >     if ((ret = ncmpi_create(MPI_COMM_WORLD, "test_pnetcdf_leak.nc",
> NC_CLOBBER,
> >                           MPI_INFO_NULL, &ncid)))
> >       return ret;
> >
> >     /* Define a global attribute. */
> >     int att_val = 42;
> >     if ((ret = ncmpi_put_att_int(ncid, NC_GLOBAL, "foo1", NC_INT,
> >                                1, &att_val)))
> >       return ret;
> >
> >     /* Close the netCDF file. */
> >     if ((ret = ncmpi_close(ncid)))
> >       return ret;
> >
> >     /* Finalize the MPI library. */
> >     MPI_Finalize();
> >
> >     return 0;
> > }
> >
> >
> >
> >
> > ==10556== Memcheck, a memory error detector
> > ==10556== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
> > ==10556== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright
> info
> > ==10556== Command: ./test_pnetcdf_leak
> > ==10556==
> > ==10556== Warning: invalid file descriptor -1 in syscall read()
> > ==10556==
> > ==10556== HEAP SUMMARY:
> > ==10556==     in use at exit: 5 bytes in 1 blocks
> > ==10556==   total heap usage: 631 allocs, 630 frees, 25,236,667 bytes
> allocated
> > ==10556==
> > ==10556== 5 bytes in 1 blocks are definitely lost in loss record 1 of 1
> > ==10556==    at 0x4A08B9D: realloc (in
> /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
> > ==10556==    by 0x4C75C68: utf8proc_map (dutf8proc.c:550)
> > ==10556==    by 0x4C75D04: utf8proc_NFC (dutf8proc.c:566)
> > ==10556==    by 0x4D3616B: ncmpii_NC_findattr (in
> /usr/local/lib/libnetcdf.so.11.0.0)
> > ==10556==    by 0x4D391C9: ncmpii_put_att (in
> /usr/local/lib/libnetcdf.so.11.0.0)
> > ==10556==    by 0x4D3969D: ncmpi_put_att_int (in
> /usr/local/lib/libnetcdf.so.11.0.0)
> > ==10556==    by 0x4009A3: main (test_pnetcdf_leak.c:23)
> > ==10556==
> > ==10556== LEAK SUMMARY:
> > ==10556==    definitely lost: 5 bytes in 1 blocks
> > ==10556==    indirectly lost: 0 bytes in 0 blocks
> > ==10556==      possibly lost: 0 bytes in 0 blocks
> > ==10556==    still reachable: 0 bytes in 0 blocks
> > ==10556==         suppressed: 0 bytes in 0 blocks
> > ==10556==
> > ==10556== For counts of detected and suppressed errors, rerun with: -v
> > ==10556== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
> > [ed at localhost unit]$
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/parallel-netcdf/attachments/20160318/37cd2367/attachment-0001.html>


More information about the parallel-netcdf mailing list