pkgsrc-Changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
CVS commit: pkgsrc/databases/py-lmdb
Module Name: pkgsrc
Committed By: adam
Date: Thu Nov 26 07:38:29 UTC 2026
Modified Files:
pkgsrc/databases/py-lmdb: Makefile PLIST distinfo
Log Message:
py-lmdb: updated to 3.0.0
3.0.0
Features
- py-lmdb now bundles both LMDB release lines and links them into a single
extension module: LMDB 0.9.36 (data format v1) and LMDB 1.0.2 (data
format v3). The two formats are mutually unreadable, so each
``Environment`` is bound to one engine at construction: an existing
database is opened with whatever engine matches its on-disk format, and a
new one uses LMDB 0.9 unless told otherwise. Databases written by either
version can therefore be opened without the caller doing anything.
- Update the bundled LMDB 0.9 tree from 0.9.35 to 0.9.36 (2026-08-06).
It brings ITS#7772 (a sub-page is no longer grown when the data being
re-added already fits), ITS#9388 (``stat()`` reported wrong
``branch_pages``/``leaf_pages`` for ``dupsort`` databases), ITS#8335
(input validation for ``MDB_MULTIPLE`` puts), ITS#10454 (metapage sync on
macOS), ITS#8590 (``SIGPIPE`` handling in the compacting copy on macOS)
and ITS#10522, which is a visible change of behaviour — see below. It
also retires two of py-lmdb's own patches: ``fix-win-flush-large-write``
was contributed upstream and landed as ITS#10538, and ``fix-large-write``
is reduced to its compacting-copy hunk now that ITS#10054 has fixed
``mdb_page_flush``.
- Update the bundled LMDB 1.0 tree from 1.0.1 to 1.0.2 (2026-09-08). Its
only code change is ITS#10575, which fixes committing a write transaction
under ``writemap=True`` on Windows with the 1.0 engine. The commit failed
with "The handle is invalid" unless ``sync=False`` or
``metasync=False`` was also given (issue #486). Every py-lmdb patch is
still needed on 1.0.2; the series was regenerated only for shifted line
numbers.
- New ``lib_version=`` argument to ``lmdb.open()``/``Environment()`` selects
the LMDB version for a *new* environment (``0`` for 0.9.x, ``1`` for
1.0.x). For an existing environment the file's own format wins. New
``Environment.lib_version()`` reports the engine backing an environment,
and ``lmdb.version()`` gained a ``lib_version=`` argument to report either
bundled version. Setting ``LMDB_DEFAULT_LIB_VERSION`` changes the default
for new environments process-wide.
- New exception classes for the error codes LMDB 1.0 adds: ``ProblemError``,
``BadChecksumError``, ``CryptoFailError`` and ``EnvEncryptionError``.
LMDB 1.0's ``MDB_IS_READONLY`` maps to the existing ``ReadonlyError``,
which 0.9 raises as ``EACCES``, so writing in a read-only transaction
raises the same class on both engines.
- New offline verifier for the "verify-then-trust" model:
``python -m lmdb verify <path>``, and the underlying
``lmdb.verify.verify(path)``. It is a pure-Python byte walker that never
hands the file to the C engine, so it is safe to run on a data file
from an untrusted source before opening it. It uses a global view of the
file to check every invariant the write paths assume — meta-page
selection, a full tree walk from the committed roots, structural bounds,
key ordering, per-database counters, the absence of dirty markers at
rest, and that the free and reachable page sets are disjoint and cover
the file. The last of these catches a coherent forged free-database
record that names a genuinely live page, the residual left over from the
``validate-freedb-record`` engine patch and issue #484 that no
per-transaction check can reach. Works on every build (patched, pure,
system, cffi); assumes a 64-bit, native-byte-order file and reports
anything else as unsupported. See "Trust model and offline verification"
in the documentation, which also states py-lmdb's threat model and the
tool's operational caveats (verify a private copy; discard a supplied
lock file; trust extends to every later co-writer) for the first time in
user-facing form.
Bug fixes
- ``Environment.dbs()`` strips the trailing NUL that LMDB 1.0 stores with
sub-database names, so it returns the same list on either engine.
- Building against a system LMDB 1.0.x (``LMDB_FORCE_SYSTEM=1``) no longer
fails the test suite (issue #493). 2.3.0 raised a plain ``lmdb.Error``
rather than ``ReadonlyError`` for a write in a read-only transaction, and
``dbs()`` returned names with a trailing NUL. Both are fixed by the 1.0
support above.
- The guard against opening one environment twice in a process (#230, added
in 2.0.0) now compares files rather than paths (issue #491). It keyed on
``os.path.realpath()``, so an environment deleted and re-created at the
same path could not be opened while an ``Environment`` on the old,
deleted files was still open -- a transaction still reading them, say --
although the two share nothing. Each environment is now identified by
the ``(st_dev, st_ino)`` of its data file and of its lock file, so that
case is allowed, while the same files reached through a hard link, which
the path check missed, are now refused. An environment whose data file
alone was replaced is still refused: it would share the lock file, and
with it the reader table and ``fcntl()`` locks, of the one still open.
Where a filesystem reports no inode number the resolved path is used as
before.
- An ``MDB_DUPFIXED`` database with 1-byte values no longer fails with
``MDB_CORRUPTED`` from the fifth duplicate onwards (issue #481,
a regression in 2.3.0 affecting both engines). py-lmdb's
``validate-subpage-bounds`` hardening patch bounded a sub-page's
``mp_upper`` by the sub-page size, which does not hold for a LEAF2
page: ``mdb_node_add`` adjusts ``mp_upper`` by
``ksize - sizeof(indx_t)``, a negative delta once the fixed key size
is below ``sizeof(indx_t)``, so it legitimately grows past the
sub-page. Unpatched LMDB was never affected.
**The defect did not corrupt data.** It rejected valid writes rather
than mis-performing them: the check runs before the page is modified,
and the error marks the transaction unusable, so the affected
transaction aborts with nothing committed. Databases were left byte
for byte as they were, remained readable, and 1-byte ``MDB_DUPFIXED``
data written by an unaffected build still read back correctly on an
affected one — only the write path consulted the faulty check.
- New ``validate-freedb-record`` hardening patch for both bundled engines:
``mdb_page_alloc()`` trusted a free-database record's structure
completely. Its element count was never checked against the record's
node size, so a forged count read past the end of the node
(``mdb_midl_xmerge`` SIGBUS) and merged garbage page numbers into the
in-memory free list. A page number taken from a record was never
range-checked either — the reuse path jumps past the bound the
fresh-page path applies — so a crafted number could be handed out
directly: under ``MDB_WRITEMAP`` the store lands outside the map
(SIGSEGV), and without it ``mdb_page_flush()`` later pwrites at an
arbitrary file offset, committing silently and growing the file
without limit. The record's node size must now equal
``(count+1)*sizeof(pgno)``, and a reused page number must fall within
``[NUM_METAS, next_pgno)`` with room for the whole run. A forged
record listing the same page twice also tripped an assertion in
``mdb_page_dirty()`` (``abort()``); it now returns ``MDB_CORRUPTED``.
As with the rest of the series this matters only if you open a database
file you do not trust. These checks are structural only: a record that
lists a genuinely live page in range still passes, which is left to an
offline verifier.
- New ``cve-2019-16225-validate-mp-txnid`` hardening patch for the bundled
LMDB 1.0 engine, restoring a protection 0.9 has had since CVE-2019-16225.
0.9 rejects a mapped page claiming ``P_DIRTY``; 1.0 removed that flag and
derives dirtiness from a new ``mp_txnid`` page field, which no read path
validated. ``mdb_page_touch()`` skips the copy-on-write for any page
whose ``mp_txnid`` is new enough, so a crafted value made it write to a
page it does not own: without ``MDB_WRITEMAP`` that is a write through a
read-only mapping (SIGSEGV), and with it the page is silently modified in
place. The 0.9 engine was never affected. As with the rest of the
series this matters only if you open a database file you do not trust.
One case is not covered, under ``MDB_WRITEMAP``; see the scope note at
the end of this section.
- New ``validate-ovpage-free`` hardening patch for both bundled engines.
``mdb_ovpage_free()`` took the overflow extent from the page header and
used it as an allocation size, as the number of page numbers appended to
the transaction's free list, and as a loop bound, without bounding it.
``validate-overflow-pages`` covered the two other sites reading that
field but not this one, so deleting a record whose value lives on
overflow pages reached it unchecked. A crafted ``data.mdb`` could
segfault the process outright, but the more serious case is a merely
large count: the delete committed silently, leaving the free database
holding page numbers past the end of the file for a later transaction to
hand out. As with the rest of the series this matters only if you open
a database file you do not trust.
- New ``validate-md-pad`` hardening patch for both bundled engines: the
LEAF2 fixed key size was bounded only on the page (``mp_pad``), never on
the database record (``md_pad``) that every LEAF2 computation actually
uses. A crafted ``data.mdb`` could set it arbitrarily while leaving
every page internally consistent, turning it into an out-of-bounds read
that silently returned adjacent mapping contents to the caller, and — via
``mdb_node_add`` — an out-of-bounds write. The key size is now bounded
both on its own and against the number of keys the page says it holds,
since ``LEAF2KEY()`` multiplies the two: a size that fits the page still
addresses far outside it partway through a full page. As with the rest
of the series this matters only if you open a database file you do not
trust. Reproducer in ``misc/md_pad_repro.py``.
- **Scope of the hardening series: it does not extend to**
``writemap=True``. py-lmdb's bundled patches harden LMDB against
hostile or damaged database files, which upstream LMDB does not treat
as an attack surface. That hardening covers the default configuration.
It does *not* cover ``MDB_WRITEMAP``, on either engine: under
``writemap=True`` a crafted page can still be taken for one the current
transaction already dirtied, which bypasses copy-on-write, so writes
land directly on pages of the previous snapshot and ``abort()`` does not
roll them back. Both engines skip the dirty-page lookup that would
distinguish the two, so nothing in the read path can tell them apart.
0.9 is affected across the board here; 1.0 only for a page forged to
exactly the next transaction's id. If you open files you do not
control, leave ``writemap`` at its default of ``False``. Tracked in
issue #484; the analysis is in ``lib1/py-lmdb/PATCH-STATUS.md``.
- **Deadlock (C extension):** ``abort()`` on a write transaction -- including
a ``with`` block exiting on an exception -- hung forever while another
thread was waiting in ``begin(write=True)`` (issue #495).
- **Crash with nested transactions (C extension):** a read-only child of a
write transaction (LMDB 1.0) crashed the process when finished, and any
child used after its parent committed or aborted touched freed memory.
Children are now finished with their parent, and a later use raises
``lmdb.Error``. Ending a child write transaction also no longer marks the
parent's writer lock as released. On CFFI a read-only child silently
ignored ``parent`` and returned an unrelated snapshot; it now works on the
1.0 engine and, on 0.9, which has no read-only children, raises
``InvalidParameterError`` on both implementations (issue #496).
- Calling ``commit()`` or ``abort()`` inside a ``with env.begin(...)`` block
no longer makes leaving the block raise on the C extension (issue #497).
- ``Environment.sync(force=True)`` is accepted by keyword on the C extension
(issue #499).
- CFFI: a write transaction begun while another thread holds one now waits
for it, as on the C extension, instead of raising ``EBUSY``; concurrent
``lmdb.aio`` write transactions therefore work on PyPy. A second write
transaction on the *same* thread still raises, on both (issue #500).
- CFFI: ``open_db()`` no longer returns a cached handle for a database
whose creating transaction aborted (issue #502).
- ``append=True`` now appends a duplicate on a ``dupsort`` database whichever
database the transaction defaults to, and ``Transaction.put(append=True)``
does so too; both used the transaction's default database's flags
(issue #504).
- ``Cursor.set_range_dup()`` leaves the cursor unpositioned when it returns
``False``, as documented, instead of on the following key (issue #505).
- ``drop(db, delete=True)`` closes the transaction's cursors on that database
on the C extension too; ``drop(db, delete=False)`` leaves them usable on
CFFI too, as LMDB does (issue #503).
- ``python -m lmdb``: ``dump --all`` is implemented, and the help text and
usage examples are corrected (issue #506).
- CFFI: an iterator whose cursor is closed between steps (by
``Cursor.close()``, ending the transaction or closing the environment) now
raises ``lmdb.Error``, as on the C extension, instead of stepping the freed
cursor. ``Cursor.key()``, ``value()`` and ``item()`` on a closed cursor
raise too, rather than reading freed or unmapped memory, which could
segfault. A ``close()`` or ``abort()`` on another thread now waits until
a cursor's ``key()``, ``value()``, ``item()``, ``getmulti()``,
``replace()`` or ``pop()`` has copied the data it read, instead of
unmapping or freeing it mid-copy.
Behaviour changes
- Storing a **zero-length value** in a ``dupsort`` database now raises
``BadValsizeError`` on the 0.9 engine, where LMDB 0.9.35 and earlier
accepted it. This is upstream ITS#10522, and it removes a divergence
rather than creating one: LMDB 1.0 already rejected it, so both engines
now behave the same. Zero-length values in non-``dupsort`` databases are
unaffected and remain valid.
- The C extension and CFFI now raise the same exceptions with the same
messages (issue #503):
- Exceptions carry ``what``, ``code`` and ``reason`` attributes on the C
extension too, and ``reason`` is a ``str`` on CFFI (it was ``bytes``).
Configuration hints such as "Please use a larger Environment(map_size=)
parameter" are appended on both.
- Using a closed or finished object raises ``lmdb.Error`` "Attempt to
operate on closed/deleted/dropped object." on CFFI too, rather than a
raw cffi ``TypeError`` or ``InvalidParameterError``.
- CFFI rejects ``putmulti()`` items that are not exactly 2-tuples, raises
``TypeError`` (``OverflowError`` for a negative ``dupfixed_bytes``) for
invalid ``getmulti()`` arguments, and ``OverflowError`` for a negative
``lib_version=``, as the C extension does.
- ``Cursor.put()`` and ``Cursor.replace()`` take the value as ``value=`` on
CFFI, as on the C extension and ``Transaction.put()``; CFFI's ``val=``
keyword is gone (issue #498).
- CFFI's ``max_spare_txns`` defaults to ``0``, matching the C extension, so
read transactions are not cached unless asked for (issue #501).
- ``python -m lmdb -r`` is now a plain flag. The old ``-r READ`` spelling
still works
To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 pkgsrc/databases/py-lmdb/Makefile
cvs rdiff -u -r1.6 -r1.7 pkgsrc/databases/py-lmdb/PLIST
cvs rdiff -u -r1.12 -r1.13 pkgsrc/databases/py-lmdb/distinfo
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: pkgsrc/databases/py-lmdb/Makefile
diff -u pkgsrc/databases/py-lmdb/Makefile:1.14 pkgsrc/databases/py-lmdb/Makefile:1.15
--- pkgsrc/databases/py-lmdb/Makefile:1.14 Thu Jul 16 11:22:38 2026
+++ pkgsrc/databases/py-lmdb/Makefile Thu Nov 26 07:38:29 2026
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.14 2026/07/16 11:22:38 adam Exp $
+# $NetBSD: Makefile,v 1.15 2026/11/26 07:38:29 adam Exp $
-DISTNAME= lmdb-2.3.0
+DISTNAME= lmdb-3.0.0
PKGNAME= ${PYPKGPREFIX}-${DISTNAME}
CATEGORIES= databases python
MASTER_SITES= ${MASTER_SITE_PYPI:=l/lmdb/}
Index: pkgsrc/databases/py-lmdb/PLIST
diff -u pkgsrc/databases/py-lmdb/PLIST:1.6 pkgsrc/databases/py-lmdb/PLIST:1.7
--- pkgsrc/databases/py-lmdb/PLIST:1.6 Wed Jun 10 13:05:50 2026
+++ pkgsrc/databases/py-lmdb/PLIST Thu Nov 26 07:38:29 2026
@@ -1,4 +1,4 @@
-@comment $NetBSD: PLIST,v 1.6 2026/06/10 13:05:50 adam Exp $
+@comment $NetBSD: PLIST,v 1.7 2026/11/26 07:38:29 adam Exp $
${PYSITELIB}/${WHEEL_INFODIR}/METADATA
${PYSITELIB}/${WHEEL_INFODIR}/RECORD
${PYSITELIB}/${WHEEL_INFODIR}/WHEEL
@@ -14,6 +14,9 @@ ${PYSITELIB}/lmdb/__main__.pyo
${PYSITELIB}/lmdb/_config.py
${PYSITELIB}/lmdb/_config.pyc
${PYSITELIB}/lmdb/_config.pyo
+${PYSITELIB}/lmdb/_envid.py
+${PYSITELIB}/lmdb/_envid.pyc
+${PYSITELIB}/lmdb/_envid.pyo
${PYSITELIB}/lmdb/aio.py
${PYSITELIB}/lmdb/aio.pyc
${PYSITELIB}/lmdb/aio.pyi
@@ -26,3 +29,6 @@ ${PYSITELIB}/lmdb/py.typed
${PYSITELIB}/lmdb/tool.py
${PYSITELIB}/lmdb/tool.pyc
${PYSITELIB}/lmdb/tool.pyo
+${PYSITELIB}/lmdb/verify.py
+${PYSITELIB}/lmdb/verify.pyc
+${PYSITELIB}/lmdb/verify.pyo
Index: pkgsrc/databases/py-lmdb/distinfo
diff -u pkgsrc/databases/py-lmdb/distinfo:1.12 pkgsrc/databases/py-lmdb/distinfo:1.13
--- pkgsrc/databases/py-lmdb/distinfo:1.12 Thu Jul 16 11:22:38 2026
+++ pkgsrc/databases/py-lmdb/distinfo Thu Nov 26 07:38:29 2026
@@ -1,5 +1,5 @@
-$NetBSD: distinfo,v 1.12 2026/07/16 11:22:38 adam Exp $
+$NetBSD: distinfo,v 1.13 2026/11/26 07:38:29 adam Exp $
-BLAKE2s (lmdb-2.3.0.tar.gz) = c13f13ce0ccac875b51a22ac311c45858dc107c6a26a911ee5668d31a958e81e
-SHA512 (lmdb-2.3.0.tar.gz) = 4e9dc23af060e20b402b8a69bb253f06f0ac9d68e09fd74a70f189f59b5b6661a9ec297bd748568717702c1316f81854407490f184f7f9a1dbaf23705f20fdc8
-Size (lmdb-2.3.0.tar.gz) = 954381 bytes
+BLAKE2s (lmdb-3.0.0.tar.gz) = 41cad00d08598a174ede1c6d7d6597d197e32d0238387aebe3dd317412b869d4
+SHA512 (lmdb-3.0.0.tar.gz) = 67247f16d448d7405737ce9a898e85adf555fe842212bb1ab12f5208fa683f61a11588b24f8e10af3fae56740f1c14540ca22dd3eac5a9202425409b07b9dd54
+Size (lmdb-3.0.0.tar.gz) = 1202795 bytes
Home |
Main Index |
Thread Index |
Old Index