This question is purely academic. TeXing a file containing
\valign{\halign#\cr!
causes an ! Emergency stop.
error. Is that the shortest code which produces a fatal error in TeX?
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this community\def\a{a\a}\a
EDIT: Shorter version, as suggested by Bruno:
\def~{~~}~
This gives I can't go on meeting you like this
:
\halign{#&&#\cr\multispan{300}}
And this gives This can't happen
:
\halign{#&&#\cr\multispan{300}\cr}
Emergency stop.
, but TeX capacity exceeded, sorry [main memory size=...].
And you can shorten that by 3 characters using the fact that ~
is active by default in TeX. I suspect that This can't happen.
is harder to achieve :).
Oct 14, 2011 at 22:27
errorstopmode
. Other solutions go to batchmode
(or nonstopmode
) and can thus crash TeX much more easily (e.g., with an empty file).
Oct 19, 2011 at 21:08
This can't happen.
unfortunately, it depends on extensions added by e-tex. i'm still looking for an example that will reliably produce This can't happen.
with knuth's unextended engine. although such an example will probably not result in changes to the tex engine, it would definitely result in wider recognition and "glory" of a sort.
Jun 15, 2012 at 13:24
\a
, on an unextended tex, results in TeX capacity exceeded, sorry [main memory size=327145]
, and the code with the tildes results in TeX capacity exceeded, sorry [input stack size=200]
. (this has already been pointed out by Bruno Le Floch.) both tested on Version 3.14159 [PD VMS 3.6]
. nice try, but i claim this isn't a valid winner.
Jun 15, 2012 at 13:54
This can't happen
example requires e-tex? I see that the same code path is present in my "Computers & Typesetting/B: TeX:The Program" book (which describes version 3.14159), in section 798 (with the comment {this can happen, but won't}
). I don't have Version 3.14159 [PD VMS 3.6]
but with Version 3.1415926 (MiKTeX 2.9 64-bit)
which doesn't seem to understand e-tex primitives such as \eTeXversion
it still gives This can't happen
. I do agree that no changes to the TeX engine are required here, though :)
Jun 15, 2012 at 15:33
A file just consisting of ^H
(IIRC the only character with catcode invalid by default in LaTeX) will do it:
[1 1016] ~/temp % echo -e '\b' | latex
This is pdfTeX, Version 3.1415926-2.3-1.40.12 (TeX Live 2011)
**entering extended mode
! Text line contains an invalid character.
<*> ^^H
?
! Emergency stop.
<*> ^^H
No pages of output.
Transcript written on texput.log.
[1 1017] ~/temp %
^H
is the backspace character and if you find explicit backspace characters in your text file, something's wrong with your terminal and/od editor :)
Oct 14, 2011 at 9:02
\newcount\foo\loop\message{\the\catcode\foo}\advance\foo1\iftrue\repeat
). I think the key reason why this crashes TeX is that somehow it is called in batch mode (e.g., putting an invalid character in a file and running TeX on it will simply prompt you for more material). Thus, echo "" | latex
also crashes, with a different error message.
Oct 14, 2011 at 22:25
?
prompt. the original challenge was to create a tex file that stops all by itself, no intervention.
Jun 15, 2012 at 14:08
{
Here's the log:
This is TeX, Version 3.1415926 (TeX Live 2011) (format=tex 2011.8.28) 14 OCT 2011 11:17
**short
(./short.tex)
! Emergency stop.
<*> short
*** (job aborted, no legal \end found)
No pages of output.
If running with -interaction=batchmode
is allowed then I win: just try
touch inexistent.tex
tex -interaction=batchmode inexistent
and you'll get
This is TeX, Version 3.1415926 (TeX Live 2011) (format=tex 2011.8.28) 14 OCT 2011 11:25
**inexistent.tex
(./inexistent.tex)
! Emergency stop.
<*> inexistent.tex
*** (job aborted, no legal \end found)
No pages of output.
The output of the shell to check:
> ls -l inexistent.tex
-rw-r--r-- 1 enricomb staff 0 Oct 14 11:25 inexistent.tex
batchmode
, because simply doing tex short.tex
leaves me with TeX prompting me for more data. I think that -interaction=batchmode
should be counted towards the number of characters :).
Oct 14, 2011 at 22:19
{
example works also in nonstopmode
. But you're right: skimming through "TeX, the program" tells that the only fatal errors in errorstopmode
are of the "interwoven alignment" kind.
*
prompt waiting for a response. i'm not sure how to specify \nonstopmode
on a vms installation except by putting the command in the tex file, but when that's done, it does result in emergency stop.
Jun 15, 2012 at 14:05
TEX /N
or something?
Another short way of making TeX blow up is to have a file named +.tex
consisting of
\input+
Then +.tex
inputs itself, and TeX sadly stops with the error
! TeX capacity exceeded, sorry [text input levels=15].
Yet another way to crash the engine: \closeout18\bye
causes a segmentation fault in pdfTeX and in XeTeX when trying to ship out the page. The last line shown on the terminal is
[1zsh: segmentation fault (core dumped) pdftex '\closeout18\bye'
x86_64-darwin
)
i386-linux
(I had tested that with TeX Live 2014).
Aug 5, 2015 at 22:45
. so here's the challenge: produce shorter code that results in
emergency stop` with knuth's original tex engine. no prizes, just glory. (and see my comments on the answers.)