-
Notifications
You must be signed in to change notification settings - Fork 664
Closed
Labels
Description
If I take a page ref, then close the doc, I eventually (after repeating a couple times) I get:
- a zero-len doc
- crashes
This look related to Should be able to close document explicitly #16.
To Reproduce
Consider this code to crawls a directory of pdf files (their content seems unimportant).
from glob import glob
import fitz
for i, f in enumerate(glob("*.pdf")):
print("i={}, file={}".format(i, f))
doc = fitz.open(f)
print(" {} pages".format(len(doc)))
front_page = doc[0] # remove this line and no crash
doc.close()
I'm not sure if that is supposed to work or not but it reliably did work in 1.16.xx. Even if its invalid it probably shouldn't be segfaulting!
Sometimes I get crashes:
i=0, file=more4.pdf
20 pages
i=1, file=more0.pdf
0 pages
Traceback (most recent call last):
File "foo.py", line 12, in <module>
front_page = doc[0] # remove this line and no crash
File "/home/cbm/.local/lib/python3.8/site-packages/fitz/fitz.py", line 3577, in __getitem__
raise IndexError("page not in document")
IndexError: page not in document
fish: Job 2, “python foo.py” terminated by signal SIGSEGV (Address boundary error)
other times just the IndexError (note: I'm using multiple copies of the same PDF file for this MWE).
Expected behavior
I'm not sure but the MWE runs without error on 1.16.18.
configuration
- Fedora 32
3.8.3 (default, May 15 2020, 00:00:00)
[GCC 10.1.1 20200507 (Red Hat 10.1.1-1)]
linux
PyMuPDF 1.17.1: Python bindings for the MuPDF 1.17.0 library.
Version date: 2020-06-13 07:54:31.
Built for Python 3.8 on linux (64-bit).
other info
Downstream issue: https://gitlab.com/plom/plom/-/issues/919