Bug 203097 - [libgeom] multiple geom_stats_open/close() leaks memory
Summary: [libgeom] multiple geom_stats_open/close() leaks memory
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 10.2-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: Alan Somers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-09-14 11:58 UTC by erik
Modified: 2021-06-17 21:08 UTC (History)
2 users (show)

See Also:
asomers: mfc-stable13+
asomers: mfc-stable12+


Attachments
Don't leak memory in geom_stats_resync (587 bytes, patch)
2021-02-27 22:48 UTC, Alan Somers
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description erik 2015-09-14 11:58:32 UTC
This program leaks non-RES memory, probably due to MAP_SHARED in the the mmap() reallocation.

<code>
#include <libgeom.h>

int main() {
	while (1) {
		geom_stats_open();
		geom_stats_close();
	}
	return 0;
}
</code>

# clang bug.c -lgeom && ./a.out
Comment 1 Alan Somers freebsd_committer freebsd_triage 2021-02-27 22:48:37 UTC
Created attachment 222869 [details]
Don't leak memory in geom_stats_resync

I classic memory leak.  The attached patch fixes the problem.  However, I think I'm going to do it a different way instead as part of https://reviews.freebsd.org/D28968, which also improves performance.
Comment 2 Alan Somers freebsd_committer freebsd_triage 2021-06-17 21:08:31 UTC
Fixed by ab63da3564e8ab0907f9d8eb565774848ffdadeb and MFCed by 2d1c164591ff5993cfca4b1190a345e40529593f and 8cfe6a4729f598d8a65d846a01184f1fabe2ebc7