On Sat, Nov 20, 2021 at 10:30:24PM +0000, Thomas Adam wrote: > On Sat, Nov 20, 2021 at 04:26:13PM +0100, Dominik Vogt wrote: > > I wonder if we should do something about these kind of functions: > > Theres the definition "MAX_FUNCTION_DEPTH 512" in defaults.h that > > prevents functions from nesting infinitely deep: > > Yeah. How likely is this problem in the real world though? As in, how many > people have actually done this? I can't say I've ever had to support a user > who has managed to get into this situation. > > Even then, what's wrong in just keeping it as it is?
Nothing. It was only a bit of context description. > > I could add an execution counter that limits the total number of > > command lines that can be executed from a single top level > > function call; maybe limit that to 1000. > > Maybe, if this is an actual problem... Probably not, but accidents happen. > > Another problem: It's possible to add items to functions that are > > currently in use. > > > > addtofunc foo i bar > > addtofunc bar i addtofunc foo i bar > > # hangs: > > foo > > I can maybe foresee this situation arising. Maybe this is worth fixing? How about 1. MAX_FUNCTION_DEPTH 100 (stricter limit) 2. MAX_FUNCTION ITEMS 1000 (limit maximum size of functions) 3. MAX_CMDS_PER_INVOCATION 10000 (max. cmds per top level function invocation) I could instead disable modifying functions that are currently in use (either directly or as an ancestor of the current function). But it sounds like a potentially useful feature. One could implement self-loading functions with it. addtofonc foo + i ((if $foo_load != 1; then Piperead build-foo-func.sh; fi)) + + ((foo_loaded=1)) Ciao Dominik ^_^ ^_^ -- Dominik Vogt