You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Every call to Page.get_texttrace() decrements the reference count of None more times than it increments it. On Python 3.11 (where None is not yet immortal) the deficit accumulates; once it exceeds None's base refcount (~12k), the interpreter dies with:
Fatal Python error: none_dealloc: deallocating None:
bug likely caused by a refcount error in a C extension
Long-running processes (batch conversion, large test suites) are affected; short single-document scripts usually stay under the threshold.
Observed output: None refcount drift: -2657 (≈ −13 per call for this page). Increase the loop count and the interpreter eventually crashes with none_dealloc. All other hot APIs we probed (get_text, get_pixmap, open/close, page_count) show a drift of exactly 0.
Details we measured
The deficit scales with span count (≈ −4/call on an empty page, dozens on dense pages).
Part of the deficit fires when the result is disposed, not at call time: at construction a legitimate INCREF(None) and an erroneous extra DECREF(None) cancel numerically, but the slot still holds a pointer to None — disposing the result later performs a real, uncompensated DECREF(None). So a simple before/after window around the bare call underestimates the leak.
Environment
PyMuPDF 1.27.2.3 (MuPDF 1.27.2) — also reproduced on 1.28.0
Python 3.11 (Windows 11 x64; also reproduced on ubuntu-latest CI)
Prior art
Looks like the same defect class as #2146 (fixed in 2023), now present in get_texttrace().
Happy to test a fix; we currently work around it with a measured compensation wrapper on our side.
Thanks for the incredibly fast turnaround! Happy to verify — we'll run our refcount-drift reproducer against the fixed build as soon as it's available (release or pre-release) and confirm here.
Activity
JorjMcKie commentedon Jul 11, 2026
Thanks for submitting this @manya4ello
I have confirmed the bug and am developing fix.
JorjMcKie commentedon Jul 11, 2026
Developed a fix and submitted to review.
manya4ello commentedon Jul 11, 2026
Thanks for the incredibly fast turnaround! Happy to verify — we'll run our refcount-drift reproducer against the fixed build as soon as it's available (release or pre-release) and confirm here.
JorjMcKie commentedon Jul 12, 2026
Thanks for your well prepared post - your reproducer is becoming part of our standard tests 👍.
julian-smith-artifex-com commentedon Aug 6, 2026
Fixed in PyMuPDF-1.28.2.