Skip to content

Commit 593b4d8

Browse files
pythongh-74573: document that ndbm can silently corrupt databases on macOS (python#113354)
* pythongh-74573: document that ndbm can silently corrupt databases on macOS The system ndbm implementation on macOS has an undocumented limitation on the size of values and can silently corrupt database files when those are exceeded. Co-authored-by: Erlend E. Aasland <[email protected]>
1 parent 6e02d79 commit 593b4d8

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

Doc/library/dbm.rst

+7
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,13 @@ This module can be used with the "classic" ndbm interface or the GNU GDBM
272272
compatibility interface. On Unix, the :program:`configure` script will attempt
273273
to locate the appropriate header file to simplify building this module.
274274

275+
.. warning::
276+
277+
The ndbm library shipped as part of macOS has an undocumented limitation on the
278+
size of values, which can result in corrupted database files
279+
when storing values larger than this limit. Reading such corrupted files can
280+
result in a hard crash (segmentation fault).
281+
275282
.. exception:: error
276283

277284
Raised on :mod:`dbm.ndbm`-specific errors, such as I/O errors. :exc:`KeyError` is raised

Doc/library/shelve.rst

+3
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ Restrictions
113113
differs across Unix versions and requires knowledge about the database
114114
implementation used.
115115

116+
* On macOS :mod:`dbm.ndbm` can silently corrupt the database file on updates,
117+
which can cause hard crashes when trying to read from the database.
118+
116119

117120
.. class:: Shelf(dict, protocol=None, writeback=False, keyencoding='utf-8')
118121

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Document that :mod:`dbm.ndbm` can silently corrupt DBM files on updates when
2+
exceeding undocumented platform limits, and can crash (segmentation fault)
3+
when reading such a corrupted file. (FB8919203)

0 commit comments

Comments
 (0)