[Date Prev][Date Next] [Chronological] [Thread] [Top]

(ITS#8455) LMDB: mdb_env_copyfd1 leaks memory and pthread state if mdb_txn_begin fails

Full_Name: Lorenz Bauer
Version: git c367c1f69685
URL: https://gist.github.com/lmb/c48dcdb74b4bc9bf4ecae1d70553d623
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[0]. 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.