|
Subject: Re: security trap mode Newsgroups: gmane.comp.tex.tetex.general Date: 2005-02-10 10:25:01 GMT (4 years, 20 weeks, 3 days, 21 hours and 6 minutes ago)
On Fri, 04 Feb 2005 18:22:10 +0100, Johannes Berg wrote:
[...]
> I have two questions about this:
> 1) from what I read in The TeXbook and the sources, there's no way
> to loop in TeX that doesn't take iterations of the main loop. Is
> that correct?
Others have already suggested using ulimit and friends. But just for
the record: no, it is not, if "main loop" means "main_control". It is
possible to create fully expandable loops, e.g.,
\def\a{\a}\a
takes a single call to main_control, and spins in get_x_token. (Making
such a loop finite is more tricky, but possible.)
BTW, if you want to limit also memory resources, do not rely on the
fact that TeX arrays have a fixed size given in texmf.cnf. Some of the
routines in TeX are recursive, and can thus use huge amount of stack (as in
OS-supplied stack, not TeX stack) before overflowing TeX memory. The
example below needs almost 10x more stack size than data size (YMMV).
[~/tex]% (ulimit -s 77000; tex '\def\a{\csname\a}\a')
This is TeXk, Version 3.14159 (Web2C 7.4.5)
%&-line parsing enabled.
! TeX capacity exceeded, sorry [main memory size=1000001].
\a ->\csname
\a
<*> \def\a{\csname\a}\a
No pages of output.
Transcript written on texput.log.
[~/tex]% (ulimit -s 76000; tex '\def\a{\csname\a}\a')
This is TeXk, Version 3.14159 (Web2C 7.4.5)
%&-line parsing enabled.
zsh: segmentation fault (; ulimit -s 76000; tex '\def\a{\csname\a}\a'; )
Emil Jerabek
|
|
|