<div dir="ltr">OK, I'll give it a try tomorrow!<div><br></div><div>Thanks,</div><div>Ed</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 18, 2016 at 6:27 PM, Wei-keng Liao <span dir="ltr"><<a href="mailto:wkliao@eecs.northwestern.edu" target="_blank">wkliao@eecs.northwestern.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi, Ed<br>
<br>
Thanks for reporting the problem.<br>
<br>
I can reproduce the same valgrind output when using 1.6.1, but not 1.7.0.<br>
The source locations pointed out by valgrind does not seem to be the cause as<br>
the files are basically the same between the two PnetCDF versions.<br>
<br>
I suggest to use 1.7.0, because some bugs have been fixed since 1.6.1 that may<br>
also fix the memory leak by accident.<br>
<span class="HOEnZb"><font color="#888888"><br>
Wei-keng<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On Mar 18, 2016, at 12:30 PM, Ed Hartnett wrote:<br>
<br>
> Howdy pnetcdf folk!<br>
><br>
> While working on the PIO library I found what appears to be a memory leak in pnetcdf.<br>
><br>
> 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.<br>
><br>
> A little experimentation shows that it is the attribute name which is being copied to a new memory location and then never freed.<br>
><br>
> Thanks,<br>
> Ed<br>
><br>
><br>
> #include <pnetcdf.h><br>
><br>
> int<br>
> main(int argc, char **argv)<br>
> {<br>
>     int ncid, ret;<br>
><br>
>     /* Initialize MPI. */<br>
>     if ((ret = MPI_Init(&argc, &argv)))<br>
>       return ret;<br>
><br>
>     /* Create the netCDF output file. */<br>
>     if ((ret = ncmpi_create(MPI_COMM_WORLD, "<a href="http://test_pnetcdf_leak.nc" rel="noreferrer" target="_blank">test_pnetcdf_leak.nc</a>", NC_CLOBBER,<br>
>                           MPI_INFO_NULL, &ncid)))<br>
>       return ret;<br>
><br>
>     /* Define a global attribute. */<br>
>     int att_val = 42;<br>
>     if ((ret = ncmpi_put_att_int(ncid, NC_GLOBAL, "foo1", NC_INT,<br>
>                                1, &att_val)))<br>
>       return ret;<br>
><br>
>     /* Close the netCDF file. */<br>
>     if ((ret = ncmpi_close(ncid)))<br>
>       return ret;<br>
><br>
>     /* Finalize the MPI library. */<br>
>     MPI_Finalize();<br>
><br>
>     return 0;<br>
> }<br>
><br>
><br>
><br>
><br>
> ==10556== Memcheck, a memory error detector<br>
> ==10556== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.<br>
> ==10556== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info<br>
> ==10556== Command: ./test_pnetcdf_leak<br>
> ==10556==<br>
> ==10556== Warning: invalid file descriptor -1 in syscall read()<br>
> ==10556==<br>
> ==10556== HEAP SUMMARY:<br>
> ==10556==     in use at exit: 5 bytes in 1 blocks<br>
> ==10556==   total heap usage: 631 allocs, 630 frees, 25,236,667 bytes allocated<br>
> ==10556==<br>
> ==10556== 5 bytes in 1 blocks are definitely lost in loss record 1 of 1<br>
> ==10556==    at 0x4A08B9D: realloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)<br>
> ==10556==    by 0x4C75C68: utf8proc_map (dutf8proc.c:550)<br>
> ==10556==    by 0x4C75D04: utf8proc_NFC (dutf8proc.c:566)<br>
> ==10556==    by 0x4D3616B: ncmpii_NC_findattr (in /usr/local/lib/libnetcdf.so.11.0.0)<br>
> ==10556==    by 0x4D391C9: ncmpii_put_att (in /usr/local/lib/libnetcdf.so.11.0.0)<br>
> ==10556==    by 0x4D3969D: ncmpi_put_att_int (in /usr/local/lib/libnetcdf.so.11.0.0)<br>
> ==10556==    by 0x4009A3: main (test_pnetcdf_leak.c:23)<br>
> ==10556==<br>
> ==10556== LEAK SUMMARY:<br>
> ==10556==    definitely lost: 5 bytes in 1 blocks<br>
> ==10556==    indirectly lost: 0 bytes in 0 blocks<br>
> ==10556==      possibly lost: 0 bytes in 0 blocks<br>
> ==10556==    still reachable: 0 bytes in 0 blocks<br>
> ==10556==         suppressed: 0 bytes in 0 blocks<br>
> ==10556==<br>
> ==10556== For counts of detected and suppressed errors, rerun with: -v<br>
> ==10556== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)<br>
> [ed@localhost unit]$<br>
<br>
</div></div></blockquote></div><br></div>