Issue 8346 - lmdb memory leak with MDB_VL32
Summary: lmdb memory leak with MDB_VL32
Status: RESOLVED TEST
Alias: None
Product: LMDB
Classification: Unclassified
Component: liblmdb (show other issues)
Version: unspecified
Hardware: All All
: --- normal
Target Milestone: 1.0.0
Assignee: OpenLDAP project
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-08 23:43 UTC by jeremiah.morrill@econnect.tv
Modified: 2020-03-16 22:50 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description jeremiah.morrill@econnect.tv 2016-01-08 23:43:46 UTC
Full_Name: Jeremiah Morrill
Version: lmdb 0.9.70
OS: Windows
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (24.120.130.199)


With MDB_VL32, I believe lmdb is leaking memory in env->txn0->mt_rpages.

Here is quick diff of what may fix this issue.  Not sure if I have redundant
null checks.

diff --git a/src/libraries/lmdb/mdb.c b/src/libraries/lmdb/mdb.c
AiAindex
11832ab..1f00a66 100644
--- a/src/libraries/lmdb/mdb.c
+++ b/src/libraries/lmdb/mdb.c
@@ -5255,14 +5255,20 @@ mdb_env_close0(MDB_env *env, int excl)
 	free(env->me_dbflags);
 	free(env->me_path);
 	free(env->me_dirty_list);
-	free(env->me_txn0);
 #ifdef MDB_VL32
+    if(env->me_txn0){
+        if(env->me_txn0->mt_rpages) {
+            free(env->me_txn0->mt_rpages);
+        }
+    }
 	{ unsigned int x;
 		for (x=1; x<=env->me_rpages[0].mid; x++)
 		munmap(env->me_rpages[x].mptr, env->me_rpages%5%5].mcnt * env->me_psize);
 	}
 	free(env->me_rpages);
 #endif
+    free(env->me_txn0);
+
 	mdb_midl_free(env->me_free_pgs);
 
 	if (env->me_flags & MDB_ENV_TXKEY) {
Comment 1 OpenLDAP project 2016-01-11 20:31:38 UTC
fixed in mdb.master
Comment 2 Howard Chu 2016-01-11 20:31:38 UTC
changed notes
changed state Open to Test
moved from Incoming to Development