[tex-live] Re: [tex-implementors] Re: bug in etex

Olaf Weber olaf at infovore.xs4all.nl
Wed Jul 14 12:10:00 CEST 2004


Olaf Weber writes:
> Philip TAYLOR writes:

>> Just by way of clarification, here are the command-line qualifiers
>> for the Pascal incantation :

>> "/noopt /check=all /float=g_float /list /debug"

>> Of these, "/Check=all" is significant (all array accesses checked).

> What is null in etex in the Pascal version?  In web2c it is defined as
> min_halfword, which is a large negative number (-@"FFFFFFF).  However,
> in the original tex.web, min_halfword equals 0.  So the reason the
> Pascal version doesn't trap may be that an invalid (null) cur_ptr,
> is still a valid array index, in contrast to web2c.

In particular, it looks like the code

if (cur_cmd=toks_register)or(cur_cmd=assign_toks) then
  begin if cur_cmd=toks_register then
    if cur_chr=mem_bot then
      begin scan_register_num;
      if cur_val<256 then q:=equiv(toks_base+cur_val)
      else  begin find_sa_element(tok_val,cur_val,false);
        if cur_ptr=null then q:=null
        else q:=sa_ptr(cur_ptr);
        end;
      end
    else q:=sa_ptr(cur_ptr)                               { <---1--- }
  else q:=equiv(cur_chr);
  if q=null then sa_define(p,null)(p,undefined_cs,null)   { <---2--- }
  else  begin add_token_ref(q); sa_define(p,q)(p,call,q);
    end;
  goto done;
  end

can get to (1) with cur_ptr=null.  When null==0, the sa_ptr(cur_ptr)
will read from mem[1], which when I checked it at that point contained
all zeros, therefore effectively assigning a null to q.  This case is
then handled at (2).

A common idiom for the use of cur_ptr is like this:
    if cur_ptr=null then #:=null at +else #:=sa_ptr(cur_ptr);

If I make a similar change (through web2c's etex.fix file, given
below) then the crashes go away.  Whether this is the _correct_ thing
to do is another matter...


% Bugfixes for etex.ch version 2.1
% Public Domain.

@x l.1163
    begin cur_val:=int_val;
@y
    begin cur_val_level:=int_val;
@z

@x l.2737
    else q:=sa_ptr(cur_ptr)
@y
    else if cur_ptr=null then q:=null else q:=sa_ptr(cur_ptr)
@z

@x l.5503
  if cur_ptr<>0 then
@y
  if cur_ptr<>null then
@z

-- 
Olaf Weber

               (This space left blank for technical reasons.)



More information about the tex-live mailing list