Bug 203097

Summary: [libgeom] multiple geom_stats_open/close() leaks memory
Product: Base System Reporter: erik
Component: kernAssignee: Alan Somers <asomers>
Status: Closed FIXED    
Severity: Affects Only Me CC: allanjude, asomers
Priority: --- Flags: asomers: mfc-stable13+
asomers: mfc-stable12+
Version: 10.2-RELEASE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
Don't leak memory in geom_stats_resync none

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