https://bugs.openldap.org/show_bug.cgi?id=10058
Issue ID: 10058 Summary: destroying robust mutexes leads to use of an uninitialized mutex Product: LMDB Version: unspecified Hardware: All OS: All Status: UNCONFIRMED Keywords: needs_review Severity: normal Priority: --- Component: liblmdb Assignee: bugs@openldap.org Reporter: jiri.novosad@gmail.com Target Milestone: ---
Created attachment 966 --> https://bugs.openldap.org/attachment.cgi?id=966&action=edit an example program to reproduce the bug
This is a regression introduced in https://bugs.openldap.org/show_bug.cgi?id=9278 .
The issue is that mdb_env_setup_locks initializes the mutex only when it gets an exclusive fcntl file lock. But there is this possible order of operations:
1. Process A opens the DB, gets an exclusive file lock, initializes the mutex, downgrades the file lock to shared and does its thing 2. Process A closes the env: it gets an exclusive lock and destroys the mutex 3. Process B opens the DB and blocks in mdb_env_excl_lock trying to get the shared lock 4. Process A finishes closing the env, closes the file descriptor and loses the file lock 5. Process B gets the shared lock, does not initialize the mutex in mdb_env_setup_locks (because it does not have the exclusive lock) 6. Process B tries to lock the mutex, but it is not initialized, pthread_mutex_lock returns EINVAL
https://bugs.openldap.org/show_bug.cgi?id=10058
--- Comment #1 from jiri.novosad@gmail.com --- I came across this bug when using Heimdal with the hdb-mdb backend, see https://github.com/heimdal/heimdal/issues/1090.
The easiest "fix" would be to destroy the mutexes only on FreeBSD, document this and tell the FreeBSD ports maintainers.
https://bugs.openldap.org/show_bug.cgi?id=10058
Quanah Gibson-Mount quanah@openldap.org changed:
What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.openldap.org/s | |how_bug.cgi?id=9278
https://bugs.openldap.org/show_bug.cgi?id=10058
Quanah Gibson-Mount quanah@openldap.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords|needs_review | Target Milestone|--- |0.9.32
https://bugs.openldap.org/show_bug.cgi?id=10058
Howard Chu hyc@openldap.org changed:
What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.openldap.org/s | |how_bug.cgi?id=10095
https://bugs.openldap.org/show_bug.cgi?id=10058
Howard Chu hyc@openldap.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |DUPLICATE
--- Comment #2 from Howard Chu hyc@openldap.org ---
*** This issue has been marked as a duplicate of issue 10095 ***
https://bugs.openldap.org/show_bug.cgi?id=10058
Quanah Gibson-Mount quanah@openldap.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |VERIFIED