Endless Loops and Stack Overflow

16 views
Skip to first unread message

albert...@ynnova.it

unread,
Jul 27, 2011, 11:15:10 AM7/27/11
to iro...@googlegroups.com, lorenzo...@ynnova.it
Hi,
 
I am Alberto and I am exploring IronJs for using it as a rules engine.
I would like to know if there is any built in feature in IronJs for handling any endless loops or stack overflow (like in case of a recursive call that never exits) that a user could eventually write in the script?
 
Thank you
Alberto

John Gietzen

unread,
Jul 29, 2011, 9:28:45 AM7/29/11
to iro...@googlegroups.com, lorenzo...@ynnova.it
Unfortunately, the best you can do is to run the scripts in another thread and set a timeout.

It is IMPOSSIBLE (in any language) to detect all possible infinite loops.

See the Wikipedia article on the halting problem: http://en.wikipedia.org/wiki/Halting_problem

Thanks!
John Gietzen

albert...@ynnova.it

unread,
Jul 30, 2011, 12:28:03 AM7/30/11
to iro...@googlegroups.com, lorenzo...@ynnova.it
Thank you John for suggestion.
 
Alberto

albert...@ynnova.it

unread,
Jul 31, 2011, 12:43:24 AM7/31/11
to iro...@googlegroups.com, lorenzo...@ynnova.it
Hi John,
 
about running the script in a separated thread and using a timeout for 'killing' in in case it is taking a too long time i agree and i think is a good solution.
 
But about the endless recoursive call...i 've seen that in this case in IronJs the Context.Execute method raises a StackOverflowException.
This is the point...it is impossibile to catch this exception. If this happens...my main process will die.
A solution could be to run the script in a separated process...but in my case for some limitation of the hosting machine/environment i cannot do it.
 
So i'm asking if there is already something in the engine of IronJs to detect this kind of problem before the StackOverflowException happens.
Something that can detect/catch that problem and then notify it in a different way, for avoiding the process die.
 
If someone already face this kind of problme...how did you solve it?
 
Bye bye
Alberto
 
Reply all
Reply to author
Forward
Message has been deleted
0 new messages