velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jochen Toppe" <joc...@jtoee.com>
Subject Re: RES: Question on recursion in macros
Date Wed, 06 Oct 2004 08:26:02 GMT
Then you'll like this one too:

#set ($mem = "12345678901234567890123456789012345678901234567890")
#foreach ($link in [1..1000000]) $set ($mem = "$mem$mem") #end

This one leads "only" to an OutOfMem and is easily fixed by overloading
the getIterator of the Uberspector and limiting the number of times a loop
may be executed.

"Too few arguments to macro"? Strange, the code leads to a StackOverflow
each time I execute it.

Jochen


> Hmm... that's interesting.  I allow arbitrary users to upload Velocity
> web pages, so I'm a bit concerned.
>
> When I tried the macro in a page with my WebApp, it didn't crash my app,
> or generate a StackOverflow.  Instead it produced 2200 "Test Info", then
> stopped with an error message:
>
> VM #showInfo: error : too few arguments to macro. Wanted 1 got 0
>
>
> My memory usage also goes up by 5M each time I refresh the page.  I guess
>  this would cause me to run out of memory eventually if it wasn't gc'd.
> I'll
> have to play with this a bit more.
>
> WILL
>
>
>
> ----- Original Message -----
> From: "Jochen Toppe" <jochen@jtoee.com>
> To: <velocity-user@jakarta.apache.org>
> Sent: Tuesday, October 05, 2004 1:10 PM
> Subject: Re: RES: Question on recursion in macros
>
>
>
>>
>> *snip*
>>
>>> apparently works and the recursion in test macro works too, it causes
>>> a stack overflow
>> *snip*
>>
>>
>> Is there any way to limit the depth of the recursion (I can't find
>> anything)? StackOverflows are nasty especially if you let dumb users
>> write templates and they feel like they can crash you app.
>>
>> #macro ( showInfo $p )
>> Info: $p
>> #showInfo($p)
>> #end
>> #showInfo("Test")
>>
>>
>> The same code also crashes in Intellij Idea when put in the file
>> templates (it used veloc) ;)
>>
>>
>> Cheers,
>> Jochen
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message