Repository navigation
Description
Description of the bug
Description
Calling page.find_tables(use_layout=True) on the first page of the attached PDF causes a native segmentation fault. The crash reproduces in a standalone Python process, outside pytest, the debugger, and application threading.
Importing pymupdf4llm is significant: layout was inactive before this import and active afterward in my environment.
Environment
Linux, 64-bit
Python 3.13.16, GCC 14.2.0
PyMuPDF 1.28.2 / MuPDF 1.28.2
PyMuPDF4LLM: 1.28.2
Minimal Reproduction
import faulthandler
import pymupdf
import pymupdf4llm
faulthandler.enable()
print(pymupdf.__doc__, flush=True)
with pymupdf.open("data/protocols/lung_cancer_ctDNA_protocol.pdf") as document:
page = document[0]
print("Calling find_tables with layout enabled", flush=True)
tables = page.find_tables(use_layout=True)
print(len(tables.tables), flush=True)
Expected Behavior
Table detection completes, or raises a Python exception, without crashing the process.
Actual Behavior
Fatal Python error: Segmentation fault
... pymupdf/extra.py, line 195 in page_get_textpage
... pymupdf/__init__.py, line 10154 in _get_textpage
... pymupdf/__init__.py, line 12356 in get_textpage
... pymupdf/layout/pymupdf_util_base.py, line 465 in create_stext_page
... pymupdf/layout/pymupdf_util_base.py, line 542 in extract_base_elements
... pymupdf/layout/pymupdf_util.py, line 53 in create_input_data_from_page
... pymupdf/layout/onnx/BoxRFDGNN.py, line 928 in predict
... pymupdf/layout/MultiProcessWrapper.py, line 156 in predict
... pymupdf/layout/__init__.py, line 20 in _get_layout
... pymupdf/__init__.py, line 10989 in get_layout
... pymupdf/table.py, line 2942 in find_tables
... pymupdf/__init__.py, line 11571 in find_tables
Segmentation fault (core dumped)
Comparison Results
Each operation was tested in a separate process:
Plain text extraction succeeds: 2,412 characters.
find_tables(use_layout=True) segfaults.
find_tables(use_layout=False) succeeds and detects one table.
A manually printed PDF from the same source document processes successfully.
Attached PDF Details
The failing PDF was exported from Word format through LibreOffice’s writer_pdf_Export:
Producer: LibreOffice 25.2.3.2 (X86_64) / LibreOffice Community
PDF 1.7, 20 pages
Failing page: index 0, dimensions 612 × 792 points
SHA-256: dc648decae17054d9c1775a5286db6e3f67e2b08385f83712608a313d8557c3f
I’m attaching both failing and passing PDFs for comparison ("_printed"). The export difference appears to trigger the crash, but I have not established that the failing PDF is malformed.
lung_cancer_ctDNA_protocol_printed.pdf
lung_cancer_ctDNA_protocol.pdf
How to reproduce the bug
Minimal Reproduction
import faulthandler
import pymupdf
import pymupdf4llm
faulthandler.enable()
print(pymupdf.__doc__, flush=True)
with pymupdf.open("data/protocols/lung_cancer_ctDNA_protocol.pdf") as document:
page = document[0]
print("Calling find_tables with layout enabled", flush=True)
tables = page.find_tables(use_layout=True)
print(len(tables.tables), flush=True)
Expected Behavior
Table detection completes, or raises a Python exception, without crashing the process.
Actual Behavior
Fatal Python error: Segmentation fault
... pymupdf/extra.py, line 195 in page_get_textpage
... pymupdf/__init__.py, line 10154 in _get_textpage
... pymupdf/__init__.py, line 12356 in get_textpage
... pymupdf/layout/pymupdf_util_base.py, line 465 in create_stext_page
... pymupdf/layout/pymupdf_util_base.py, line 542 in extract_base_elements
... pymupdf/layout/pymupdf_util.py, line 53 in create_input_data_from_page
... pymupdf/layout/onnx/BoxRFDGNN.py, line 928 in predict
... pymupdf/layout/MultiProcessWrapper.py, line 156 in predict
... pymupdf/layout/__init__.py, line 20 in _get_layout
... pymupdf/__init__.py, line 10989 in get_layout
... pymupdf/table.py, line 2942 in find_tables
... pymupdf/__init__.py, line 11571 in find_tables
Segmentation fault (core dumped)
PyMuPDF version
1.28.2
Operating system
Linux
Python version
3.13
Activity
JorjMcKie commentedon Oct 18, 2026
Thanks for the submission. Reproduced the problem.
@veget-able - what do you think?JorjMcKie commentedon Oct 18, 2026
@veget-able -
I did a few first checks: the crash is not inside
page.find_tables()but happens already when calling the layout module i.e.page.get_layout().(One of) the difference(s) between pages 0 of both documents is the use of
/StructParents 0: it is present in the failing case only.When removing this PDF key, the crash will not occur.
So, this will crash:
And this will work:
JorjMcKie commentedon Oct 18, 2026
This appears to be a MuPDF problem. Forwarding to their issue system.
Link to Bugzilla Issue: https://bugs.ghostscript.com/show_bug.cgi?id=709841
JorjMcKie commentedon Nov 5, 2026
@alexsukhrin please open a separate issue with this and remove your post here.
In the new issue, please provide a reproducing PDF example and the script you are using to reproduce. We are unable to deal with the problem otherwise.