[Date Prev][Date Next]
(ITS#8455) LMDB: mdb_env_copyfd1 leaks memory and pthread state if mdb_txn_begin fails
- To: openldap-its@OpenLDAP.org
- Subject: (ITS#8455) LMDB: mdb_env_copyfd1 leaks memory and pthread state if mdb_txn_begin fails
- From: firstname.lastname@example.org
- Date: Tue, 28 Jun 2016 09:52:09 +0000
- Auto-submitted: auto-generated (OpenLDAP-ITS)
Full_Name: Lorenz Bauer
Version: git c367c1f69685
OS: OS X
Submission from: (NULL) (2a06:98c0:1000:1200:1160:b579:2042:d902)
In case that mdb_txn_begin fails (e.g. due to no more reader slots available),
mdb_env_copyfd1 leaks my.mc_wbuf. From the pthread_create man pages, it seems
like it also leaks pthread state, since the created thread is never joined.
The linked gist contains a test case, valgrind output which confirms that the
buffer is leaked, and a patch.
The patch properly frees the buffer, and always joins the thread. If the thread
was never created pthread_join simply returns an error, which is ignored
anyways. I think the same logic holds on Windows.