Re: [PATCH] dash: Fix stack overflow from infinite recursion in script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>  > +static int evalcount;                /* number of nested evalfun calls */
>  ...
>  > +             if (evalcount++ >= MAX_RECURSION)
>  > +                     sh_error("Maximum function recursion depth (%d) \
>  ...
>  > +#define MAX_RECURSION 1000   /* maximum recursion level */
>
> A couple of years ago i discovered mksh was crashing due to not
> having such a limit, and in the discussion which started with
> Thorsten (the mksh developer) it became obvious that a then-new
> bash seemed to have stopped using a limit; Thorsten's point was
> that the real limit can only be artitificial or very costly (if
> i recall correctly).  By then i sent Mr. Xu a message in private
> with i think a summary of all that, but never got any response.
> I know that the Lua scripting language seems be in the process of
> introducing such a limit with the upcoming release.

A recursion limit is not without precedent. CPython sets a platform-
dependent recursion limit for this same purpose:

https://docs.python.org/3/library/sys.html#sys.setrecursionlimit

But indeed, the limit is "artificial" or arbitrary. It should just be
"enough" that it isn't hit often with typical use.



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux