Skip to content

consolidate/compile-check hangs: pdflatex nonstopmode deadlocks on high-error TeX files #63

@kiki830621

Description

@kiki830621

Bug

macdoc pdf compile-check and macdoc pdf consolidate hang indefinitely when the input .tex file contains many errors.

Root Cause

TexCompileChecker invokes pdflatex -interaction=nonstopmode. On files with 100+ errors:

  1. pdflatex hits the hardcoded 100-error limit and emits (That makes 100 errors; please try again.)Fatal error occurred, no output PDF file produced!
  2. However, in nonstopmode, certain error types (group mismatch, missing }) cause pdflatex to not terminate cleanly — it hangs at 0% CPU waiting for something.
  3. macdoc's process is waiting for pdflatex's stdout/stderr to close → deadlock.

Observed Behavior

  • pdflatex -interaction=nonstopmode hangs (CPU 0%, indefinitely)
  • pdflatex -interaction=batchmode completes (exits with error code 1, produces log)
  • pdflatex -interaction=scrollmode also completes

Reproduction

# 741-page Wooldridge textbook, AI-transcribed with ~300+ LaTeX errors
macdoc pdf init --pdf wooldridge.pdf --output wooldridge-latex
macdoc pdf segment --project wooldridge-latex
macdoc pdf render --project wooldridge-latex
macdoc pdf blocks --project wooldridge-latex
macdoc pdf transcribe-pages --project wooldridge-latex --backend codex
macdoc pdf chapters --project wooldridge-latex
macdoc pdf assemble --project wooldridge-latex --skip-compile

# These hang:
macdoc pdf compile-check --project wooldridge-latex   # hangs
macdoc pdf consolidate --project wooldridge-latex --agent claude  # hangs at compile step

Suggested Fix

  1. Use batchmode instead of nonstopmode in TexCompileChecker — batchmode always terminates
  2. Add a timeout (e.g., 120s) to the pdflatex subprocess — kill it if it doesn't exit
  3. Pipe stdin from /dev/null to prevent pdflatex from waiting for user input on certain errors

All three would independently fix the deadlock. Combining (1) + (2) would be most robust.

Environment

  • macdoc v0.4.0
  • pdfTeX 3.141592653-2.6-1.40.27 (TeX Live 2025)
  • macOS 15.3 (Darwin 25.3.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions