[plt-scheme] Limiting the damage caused by infinite recursion

From: Daniel Yoo (dyoo at WPI.EDU)
Date: Wed Feb 7 11:53:15 EST 2007

> If a student writes an infinitely recursive function and doesn't realize 
> what they've done, their process eats up more and more memory until the 
> whole lab runs out of RAM, we start using virtual memory, and the whole 
> lab grinds to a halt until I can log in and kill the offending process.
> Is there any way to set a limit on the number of recursive calls or the 
> amount of memory a function call can consume so that this doesn't 
> happen?

One way to do this might be to take something like engines, and adjust 
them to keep track of recursive calls and stop things from running after a 
certain number of function applications.  Jens Axel Sooegard wrote about 
this a while back:


I took Jens's code and made it into a language to provide SICP's 
concurrency primitives:


It actually shouldn't be too bad to twist this to do what you want, to 
limit evaluation to a certain number of function applications.

Posted on the users mailing list.