https://bugs.openldap.org/show_bug.cgi?id=9278
--- Comment #4 from Howard Chu hyc@openldap.org --- (In reply to Xin Li from comment #3)
Created attachment 738 [details] Proposed patch
Oops, yes you are right and I clearly have some misunderstanding of the code here, sorry for the noise.
Here is a different proposal, basically, it would destroy the robust mutex if we are the only remaining user. My understanding of https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02. html#tag_15_09_09 was that the effect after unmapping of the mutex object is undefined, on FreeBSD, it seems to confuse the threading library because after the last mmap is gone, the kernel GC's the object, while it's still on userland threading library's bookkeeping ( https://svnweb.freebsd.org/base/head/lib/libthr/thread/thr_pshared. c?annotate=297141#l220 ) if they are not destroyed.
Last time I checked, FreeBSD didn't even support robust process shared mutexes. What OS revision is required for this to be supported?
It seems to me that doing what this test program is doing is a misuse of the API, you should only ever open an environment once in any particular process. Closing it and then opening it again makes no sense.