Skip to content

Fix: segfault when uploading multiple PDF attachments concurrently - #93

Open
lauty95 wants to merge 1 commit into
frappe:developfrom
lauty95:fix-pdf-concurrent-segfault
Open

Fix: segfault when uploading multiple PDF attachments concurrently#93
lauty95 wants to merge 1 commit into
frappe:developfrom
lauty95:fix-pdf-concurrent-segfault

Conversation

@lauty95

@lauty95 lauty95 commented Aug 7, 2026

Copy link
Copy Markdown

Problem

Uploading two PDF attachments to a chat close together can crash the whole bench start process. Not recoverable — needs a full restart.

Screen.Recording.2026-08-07.at.12.37.21.PM.mov

Error

Fatal Python error: Segmentation fault
...
File "flow/knowledge/extract.py", line 212 in _render_page_png
File "flow/knowledge/extract.py", line 178 in _extract_pdf_page
File "flow/flow/doctype/flow_session_attachment/flow_session_attachment.py", line 56 in extract_attachment

The frontend fires one upload_file request per attached file, so two PDFs upload as two concurrent requests, each extracting text synchronously on its own thread

pypdfium2 wraps PDFium. Two threads calling into it at once corrupts its state and segfaults the process.

Fix

Serializes all PDF processing in flow/knowledge/extract.py behind a single process-wide lock, so two PDFs uploaded together now get processed one after the other instead of racing.

Screen.Recording.2026-08-07.at.12.38.39.PM.mov

@greptile-apps

greptile-apps Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge.

All PDF rendering paths are covered by the lock, and the regression test exercises concurrent access.

Reviews (1): Last reviewed commit: "fix: serialize PDF extraction to prevent..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant