[squeak-dev] Re: SUnit infinite loop detection

nicolas cellier ncellier at ifrance.com
Sun Jul 6 08:55:28 UTC 2008


tim Rowledge a écrit :
> 
> On 5-Jul-08, at 9:58 PM, Colin Putney wrote:
> 
>>
>> On 5-Jul-08, at 5:49 PM, nicolas cellier wrote:
>>
>>> And i am still interested by a way to assert infinite iterative loop 
>>> (the whileTrue/whileFalse case). Anyone has an idea about it?
>>
>> Wouldn't that involve solving the halting problem?
> Well to quote one of my siglines
> "The theorists have proven that this is impossible, but there's three of 
> us and we're smart..."
> Hmm, and right next it it -
> "For those of you who are into writing programs that are as obscure and 
> complicated as possible, there are opportunities for... real fun here"
> That about covers it.
> 
> tim
> -- 

Ah yes, thank you to remind me, this is impossible.
I'm not smart enough to fight such powerfull proofs.
Sorry, i'm just an engineer...

I'm dumbfully pragmatic and just want to provide a hint on the loop count.
This work for recursive loops thanks to stack depth Context spying.
Unfortunately (fortunately!), #WhileTrue and the like are optimized with 
the jump byte code.

If anyone has an idea not as heavy as a simulator, I take it.
A kind of VM instrumentation support would be great...
A VM could count number of backward jump per Context... (i know, Context 
slot are not cheap).

By now, i use a wall clock threshold.
This hint is by far more rough than a loop counter...
It is very sensitive to underlying hardware.
Well spy process also is, due to the delay between two probes.
That would deserve some kind of calibration to be reset at 
#returnFromSnapshot!

Finally, i could tally it myself the hard way with the spy process: 
observe instruction counter of each context in the stack, compare to 
previous snapshot and increment a backward loop counter. But i guess it 
would be statistically biased. If first instructions in the loop are 
fast, and last is long, i might not be able to detect a loop at all...

Nicolas




More information about the Squeak-dev mailing list