Message-ID: Pine.LNX.4.10.10003190334280.32374-100000@bug.trap.mtview.ca.us
To: Robert Colquhoun <rjc@trump.net.au>
Subject: Re: faxq maxing out CPU - let's crack this!!!!!
From: Tom Lear <tom@trap.mtview.ca.us>
Date: Sun, 19 Mar 2000 03:40:55 -0800 (PST)
cc: hylafax-devel@hylafax.org, bugs@hylafax.org, flexfax@sgi.com, "M. Dragon" <dragondm@integral.org>, Jay Davis <Jay_Davis@compuserve.com>, tiff@olympiakos.com, Carsten Hoeger <choeger@suse.de>, mike@onshore.com
In-Reply-To: <4.2.0.58.20000319170035.00d0cea0@postoffice.trump.net.au>
Sender: owner-tiff@olympiakos.com


On Sun, 19 Mar 2000, Robert Colquhoun wrote:

> It is looping continuously in the for loop starting at line 341 to 359
> 
> Somehow: TabEnt->State = S_MakeUpB, a0 = 0, RunLength = 0 and TabEnt->Param = 0
> 
> (section of code starting at line 341)
>          for (;;) {                                                      \
>              LOOKUP16(13, TIFFFaxBlackTable, eof1d);                     \
>              switch (TabEnt->State) {                                    \
>              case S_EOL:                                                 \
>                  EOLcnt = 1;                                             \
>                  goto done1d;                                            \
>              case S_TermB:                                               \
>                  SETVAL(TabEnt->Param);                                  \
>                  goto doneBlack1d;                                       \
>              case S_MakeUpB:                                             \
>              case S_MakeUp:                                              \
>                  a0 += TabEnt->Param;                                    \
>                  RunLength += TabEnt->Param;                             \
>                  break;                                                  \
>              default:                                                    \
>                  unexpected("BlackTable", a0);                           \
>                  goto done1d;                                            \
>              }                                                           \
>          }
> 
> Possibly something funny is happening in the LOOKUP16 function, or perhaps 
> earlier there is an error that leads to this situation.
> 
> PS I am having trouble debugging this - nested defines which expand to 
> hundreds of lines of code, many variables, goto's all over the place...its 
> as if the author saw hell in a dream, then woke up and had to write about 
> it and the result is this code!

I've been in this hell before... and printf's are your friend...  I'd add
printf's to the different cases (and to the LOOKUP16 function/macro) until
I found the problem.  I'd also add a limit to that loop (abort() when a
counter reached a certain value), so I didn't have to keep hunting down
the process and killing it.
                                                        - Tom



