One Wrong Word in Typst's Eval Caused Uncatchable Stack Overflow on Recursive Import
A bug in Typst, the Rust-based typesetting system, caused the program to crash with a native stack overflow instead of returning a clean error when a document used the #eval() function to recursively import itself. The issue, tracked as typst/typst#8632, could be reproduced with a single line of code and resulted in no PDF output, no diagnostic message, and no usable exit code. The root cause was traced to the eval_string function in the typst-eval crate, where the route parameter was initialized with Route::default() instead of Route::extend(route), effectively stripping all call-chain history. Because Typst's cyclic-import and recursion-depth guards both rely on that route chain, every #eval() call appeared to the engine as a brand-new, depth-zero evaluation, bypassing both protections entirely. The fix required changing a single word in the source code so that eval_string inherits the caller's route context rather than starting from an empty one.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in