Skip to content

LMDB support is broken #2601

Closed
Closed
@hyc

Description

@hyc

lmdb.cc misuses the LMDB API in multiple ways

The code calls mdb_dbi_open/mdb_dbi_close in multiple locations without any concurrency protection.
The API doc clearly states that mdb_dbi_open must not be called from multiple transactions at once.
The doc also clearly states that mdb_dbi_close is not protected at all and must never be called from
more than one thread at once. The doc also states that programs SHOULD only call mdb_dbi_open
once, when the environment is created, and should only call mdb_dbi_close when the env is being
destroyed.

http://www.lmdb.tech/doc/group__mdb.html#ga52dd98d0c542378370cd6b712ff961b5
http://www.lmdb.tech/doc/group__mdb.html#ga52dd98d0c542378370cd6b712ff961b5

The code calls mdb_txn_abort on invalid transactions after mdb_txn|_commit fails. The doc clearly
states that after mdb_txn_commt has been called, the txn handle is freed. As such, passing the handle
the txn_abort references freed memory and triggers undefined behavior.

http://www.lmdb.tech/doc/group__mdb.html#ga846fbd6f46105617ac9f4d76476f6597

Logs and dumps

A crash caused by these bugs has been reported here https://bugs.openldap.org/show_bug.cgi?id=9626

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions