# [tex-k] segfault in texlive2020 pdftex/luatex/xetex/ptex/...

Doug McKenna doug at mathemaesthetics.com
Tue Jun 2 00:14:45 CEST 2020

FWIW,

If I run

\def\z{\number\z}\z

on my TeX language interpreter, itself running on my MacOS 10.15 laptop with 16GB memory, it seg faults just above 20000 recursive loops (each loop comprising four intermediate routines' stack frames, similar to what Karl reported).  The numbers for amount of memory used are also hard to predict because it can depend on what arguments different interpreters push onto those stack frames.  TeX's arguments-in-stack-frames overhead is about as minimal as one can get.

My code can catch C runtime recursive expansion loops that reach some limit, so that the interpreter can panic and explain to the user and halt the job.  Currently I set it to 5000.  But it's a constant compiled into the code, not a settable parameter.  I have no idea what crazy but legitimate TeX source code that amount, or any other given amount, might preclude.

Doug McKenna
Mathemaesthetics, Inc.