summaryrefslogtreecommitdiff
path: root/Build
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2008-01-02 01:06:30 +0000
committerKarl Berry <karl@freefriends.org>2008-01-02 01:06:30 +0000
commitc944d561018449d621c32bd493e8f3705a73b71a (patch)
treefc06521b44063b1a801a849d3c252406630b78c6 /Build
parent54839d302f99db85eaf56803be35707080e0299d (diff)
expansion check from Jonathan
git-svn-id: svn://tug.org/texlive/trunk@6024 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rw-r--r--Build/source/texk/web2c/ChangeLog5
-rw-r--r--Build/source/texk/web2c/tex.ch45
2 files changed, 50 insertions, 0 deletions
diff --git a/Build/source/texk/web2c/ChangeLog b/Build/source/texk/web2c/ChangeLog
index 7511283e3e4..355326c1ed9 100644
--- a/Build/source/texk/web2c/ChangeLog
+++ b/Build/source/texk/web2c/ChangeLog
@@ -1,3 +1,8 @@
+2008-01-02 Jonathan Kew <jonathan_kew@sil.org>
+
+ * tex.ch (expand_depth, et al.): when calling expand, don't
+ recurse enough to clobber the os stack. Default value 10000.
+
2007-12-24 Karl Berry <karl@tug.org>
* doc/web2c.texi (gftodvi invocation): talk a bit more about slant
diff --git a/Build/source/texk/web2c/tex.ch b/Build/source/texk/web2c/tex.ch
index 4b0a0d443b9..2626b237831 100644
--- a/Build/source/texk/web2c/tex.ch
+++ b/Build/source/texk/web2c/tex.ch
@@ -282,6 +282,9 @@ versions of the program.
@!sup_hyph_size = ssup_hyph_size;
@!inf_hyph_size = iinf_hyphen_size; {Must be not less than |hyph_prime|!}
+
+@!inf_expand_depth = 10;
+@!sup_expand_depth = 10000000;
@z
@x [1.12] l.427 - Constants that are WEB numeric macros.
@@ -594,6 +597,7 @@ tini@/
@!save_size:integer; {space for saving values outside of current group; must be
at most |max_halfword|}
@!dvi_buf_size:integer; {size of the output buffer; must be a multiple of 8}
+@!expand_depth:integer; {limits recursive calls to the |expand| procedure}
@!parse_first_line_p:c_int_type; {parse the first line for options}
@!file_line_error_style_p:c_int_type; {format messages as file:line:error}
@!eight_bit_p:c_int_type; {make all characters printable by default}
@@ -1814,6 +1818,46 @@ end
while k < limit do begin print_buffer(k) end;
@z
+@x [25.366] expansion depth check
+The |expand| subroutine is used when |cur_cmd>max_command|. It removes a
+@y
+@ Sometimes, recursive calls to the following |expand| routine may
+cause exhaustion of the run-time calling stack, resulting in
+forced execution stops by the operating system. To diminish the chance
+of this happening, a counter is used to keep track of the recursion
+depth, in conjunction with a constant called |expand_depth|.
+
+This does not catch all possible infinite recursion loops, just the ones
+that exhaust the application calling stack. The actual maximum value of
+|expand_depth| is outside of our control, but the initial setting of
+|10000| should be enough to prevent problems.
+@^system dependencies@>
+
+@<Global...@>=
+expand_depth_count:integer;
+
+@ @<Set init...@>=
+expand_depth_count:=0;
+
+@ The |expand| subroutine is used when |cur_cmd>max_command|. It removes a
+@z
+
+@x [25.366]
+begin cv_backup:=cur_val; cvl_backup:=cur_val_level; radix_backup:=radix;
+@y
+begin
+incr(expand_depth_count);
+if expand_depth_count>=expand_depth then overflow("expansion depth",expand_depth);
+cv_backup:=cur_val; cvl_backup:=cur_val_level; radix_backup:=radix;
+@z
+
+@x [25.366]
+cur_order:=co_backup; link(backup_head):=backup_backup;
+@y
+cur_order:=co_backup; link(backup_head):=backup_backup;
+decr(expand_depth_count);
+@z
+
@x [25.372] - encTeX: we need to distinguish \endcsname and \endmubyte
if cur_cmd<>end_cs_name then @<Complain about missing \.{\\endcsname}@>;
@y
@@ -4571,6 +4615,7 @@ begin @!{|start_here|}
setup_bound_var (50)('half_error_line')(half_error_line);
setup_bound_var (79)('max_print_line')(max_print_line);
setup_bound_var (0)('hash_extra')(hash_extra);
+ setup_bound_var (10000)('expand_depth')(expand_depth);
const_chk (mem_bot);
const_chk (main_memory);