-
Notifications
You must be signed in to change notification settings - Fork 266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory leaks due to NC4_provenance_init #1168
Comments
@gsjaardema are you getting these errors from a netcdf test? Or some of your code? When I run the netcdf tests with changes from @DennisHeimbigner 's branch, I get no memory leaks in netCDF tests... |
@edhartnett These are from my code. |
I can get the same/similar results from the following:
Valgrind shows:
|
I moved the leak fixing to the leaks.tmp branch.
|
I still get the same leaks on the leaks.tmp branch. They are in the "still reachable" category, but would be nice if there was a way to get rid of them. |
Unfortunately, the -fsanitize=address in gcc does not appear to show |
Spoke too soon; I see your example. |
@DennisHeimbigner it would be great if the dap code did not leak. We have been leak free with asan for some time with --disable-dap --disable-utilities. This is what I am testing in my CI with the address santizer. |
I used it to see if it helps. Here is the boiled down example:
|
@DennisHeimbigner I think that tracking down the globals shouldn't be too difficult as they all arise from memory allocated in Looks like all we need is a Maybe something like:
|
Houston, we have a problem. The memory returned by e.g. nc_get_vara BTW, the current leaks.tmp passes -fsanitize except for:
|
Can you outline the significant changes it would require? I'm inclined to not hold up the release on what is a bit of an edge case; vlens are used, of course, but don't appear to be a common feature. Are the tests that use ncgen failing for the same reason? Or are they simply yet to be fixed? |
At Ed's request, I've held off on the rc2 release until we get the memory errors fixed, but if we can get the bulk of them fixed (and good job on that!) for the release candidate, I'd be happy enough to put out RC2 and see if we can get them completely ironed out for the full release. |
The leaks due to nested complex types are known, at least in the attributes. I would suggest that we simply need to keep moving forward. So the next release should have at least no leaks in nctest/nc_test/nc_test4 for --disable-dap --disable-utilities. Utilities and DAP have leaked and those leaks should not hold up the release, IMO. However I would be very happy to see progress on leaks in these areas. After the major issues I'm now working on (separating HDF5 from libsrc4, and lazy var reads), I can take a spin at freeing complex structs better within the library. |
I just added globalpropinfo cleanup to leaks.tmp |
The ncgen leaks should be fixable. I will finish that off. Basically, I think what we need is a generalization of nc_free_vlen(s) in which |
Thanks. |
@DennisHeimbigner I believe you are seeing a manifestation of #541. |
The current situation is this:
|
Examples and HDF4 are part of my CI. They're good now, on my branch that includes your recent fixes for the nc4info leak. I will check asan parallel builds and pnetcdf builds... |
pnetcdf builds fail, but parallel builds without pnetcdf pass. I am only using a subset of memory fixes. I suggest you merge what you have and I'll retry. |
#1168 #1163 #1162 This PR partially fixes memory leaks in the netcdf-c library, in the ncdump utility, and in some test cases. The netcdf-c library now runs memory clean with the assumption that the --disable-utilities option is used. The primary remaining problem is ncgen. Once that is fixed, I believe the netcdf-c library will run memory clean with no limitations. Notes ----------- 1. Memory checking was performed using gcc -fsanitize=address. Valgrind-based testing has yet to be performed. 2. The pnetcdf, hdf4, and examples code has not been tested. Misc. Non-leak changes 1. Make tst_diskless2 only run when netcdf4 is enabled (issue 1162) 2. Fix CmakeLists.txt to turn off logging if ENABLE_NETCDF_4 is OFF 3. Isolated all my debug scripts into a single top-level directory called debug 4. Fix some USE_NETCDF4 dependencies in nc_test and nc_test4 Makefile.am
#1168 #1163 #1162 This PR partially fixes memory leaks in the netcdf-c library, in the ncdump utility, and in some test cases. The netcdf-c library now runs memory clean with the assumption that the --disable-utilities option is used. The primary remaining problem is ncgen. Once that is fixed, I believe the netcdf-c library will run memory clean with no limitations. Notes ----------- 1. Memory checking was performed using gcc -fsanitize=address. Valgrind-based testing has yet to be performed. 2. The pnetcdf, hdf4, and examples code has not been tested. Misc. Non-leak changes 1. Make tst_diskless2 only run when netcdf4 is enabled (issue 1162) 2. Fix CmakeLists.txt to turn off logging if ENABLE_NETCDF_4 is OFF 3. Isolated all my debug scripts into a single top-level directory called debug 4. Fix some USE_NETCDF4 dependencies in nc_test and nc_test4 Makefile.am
I believe this issue is now fixed and should be closed. |
I agree, will revisit if somebody comments to the contrary. |
Environment Information
configure
)C
code to recreate the issue?Summary of Issue
When running the current HEAD version of NetCDF using valgrind, I get memory leaks. All leaks have
NC4_provenance_init
called fromnc_initialize()
in the valgrind call tree.I have added a call to
nc_finalize()
to my code, but the leaks are still there. Should there be aNC4_provenance_finalize()
or something similar call, or is there an existing function that I am not calling correctly.Here is the list of leaks found by valgrind:
I see that @DennisHeimbigner is working on memory leaks in the
infoleak.dmh
branch and the above results are with those changes already applied.Thanks,
The text was updated successfully, but these errors were encountered: