[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gm2] M2LexBuf.mod problem with CurrentTokNo and ListOfTokens.LastBu
From: |
Gaius Mulley |
Subject: |
Re: [Gm2] M2LexBuf.mod problem with CurrentTokNo and ListOfTokens.LastBucketOffset |
Date: |
28 Oct 2008 16:34:55 +0000 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 |
Scott Robinson <address@hidden> writes:
> Hi Gaius,
>
> I think there is a problem in M2LexBuf.mod with CurrentTokNo and
> ListOfTokens.LastBucketOffset. These are both declared as CARDINALs
> and at lines 491 and 493 in procedure GetToken, you are subtracting
> ListOfTokens.LastBucketOffset from CurrentTokNo implying that
> CurrentTokNo is supposed to be strictly greater than or equal to
> ListOfTokens.LastBucketOffset (otherwise you'd get a very large
> CARDINAL value). At line 811 in procedure AddTokToList, you increment
> ListOfTokens.LastBucketOffset by MaxBucketSize but don't do anything
> with CurrentTokNo. This evidently can lead to CurrentTokNo being less
> than ListOfTokens.LastBucketOffset which, in the scenario I stumbled
> on, caused GetToken() to recurse enough to segmentation fault due to
> stack exhaustion.
Hi Scott,
interesting - I've now added an assert to 491:
Assert(CurrentTokNo>=ListOfTokens.LastBucketOffset) ;
Do you have some test code which causes the compiler to fall over?
> By the way, thanks for the quick fixes on the "preprocessor" problem
> and the "returning a string constant" problem. Those are both working
> fine now.
no problem - I've modified it slightly today to preserve the constant
for a little longer in the hope that better code will be generated.
I will check it in soon..
regards,
Gaius