Skip to content

GOTEX_TRACE: a runaway names the macro that loops - #358

Merged
tannevaled merged 1 commit into
mainfrom
runaway-trace
Sep 12, 2026
Merged

tannevaled merged 1 commit into
mainfrom
runaway-trace

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

A runaway is the hardest failure this engine reports to act on. The error names the line the document died on, which is almost never the line at fault: loading pgf's parser module (\usepgfmodule{parser}, reached from \usetikzlibrary{svg.path}) reports 6:15 — the document's own \end{document} — for a loop that starts hundreds of expansions earlier, inside pgfkeys. Bisecting the 697-line module by truncation answered nothing, because a half-read file breaks in its own way.

With GOTEX_TRACE set, tripRunaway prints two windows instead:

gotex: runaway at 10:14
  FIRST expansions after the input last moved forward:
    \pgfkeys@parse
    \pgfkeys@possiblerelax
    \pgfkeys@mainstop  x283
  LAST expansions:
    \pgfkeys@mainstop  x400

The first window is where the loop begins, with its caller still in view; the second is what it repeats. Runs are collapsed, so the loop cannot push the caller out of its own report. On the module above the answer was one line, and it named a pgfkeys sentinel — \def\pgfkeys@mainstop{\pgfkeys@mainstop}, "equals only itself" — being expanded where it should have been matched as a delimiter.

Off by default: nothing is recorded and nothing is allocated unless the variable is set. The report goes to traceOut (os.Stderr) so a test can read it back, and both states are tested.

🤖 Generated with Claude Code

A runaway is the hardest failure this engine reports to act on. The error names
the line the document DIED on, which is almost never the line at fault: loading
pgf's parser module (\usepgfmodule{parser}, reached from \usetikzlibrary
{svg.path}) says "6:15" — the document's \end{document} — for a loop that starts
hundreds of expansions earlier, inside pgfkeys. Bisecting the 697-line module by
truncation answered nothing, because a half-read file breaks in its own way.

With GOTEX_TRACE set, tripRunaway prints two windows instead: the FIRST
expansions since the input last moved forward (where the loop begins, with its
caller) and the LAST ones (what it repeats). Runs are collapsed — "\pgfkeys@
mainstop x400" — so the caller is not pushed out of the report by the loop
itself. On the module above the answer was one line, and it named a pgfkeys
sentinel (\def\pgfkeys@mainstop{\pgfkeys@mainstop}, "equals only itself") being
EXPANDED where it should have been matched.

Off by default: the recorder does nothing and allocates nothing unless the
variable is set, and the report goes to traceOut (os.Stderr) so a test can read
it back.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit c9a02ca into main Sep 12, 2026
18 checks passed
@tannevaled
tannevaled deleted the runaway-trace branch September 12, 2026 14:30
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