Details
Description
In some circumstances ForestDB can leak pthreads; the thread sanitizer in the new Xcode 8 beta reports this in a few of my unit tests.
It looks like the problem occurs when:
- filemgr_prefetch creates a new thread and stores its handle in file->prefetch_tid (filemgr.cc:628)
- filemgr_free_func is called when the database closes, but its prefetch_state is not FILEMGR_PREFETCH_RUNNING, so it does not call thread_join on the prefetch_tid. (filemgr.cc:1370-1375)
There are no other API calls that use prefetch_tid, so nothing else will terminate that thread.
NOTE: I'm on forestdb commit fd41b293, from the stable branch as of 4/23.