Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Crash when completion script call itself.

On Fri, 29 Sep 2017 20:25:44 +1300
Nicolas Desprès <nicolas.despres@xxxxxxxxx> wrote:
> $ cat >~/.zsh/Completion/_crash <<EOF
> #compdef crash
> _crash "$@"
> $ exec zsh
> $ crash [TAB] zsh: segmentation fault  zsh

This is certainly a real problem that people hit, but unfortuately
there's not a lot we can do to make a general robust fix.

There is already a check in the shell for the function recursion level;
the default value is 1000 (it is configurable at build time).  Some
systems will get this far without crashing, as mine does, and I get

_recurse: maximum nested function level reached

which is what's supposed to happen.

However, it's inevitable that systems vary in the resources they have
available so a single hard and fast limit doesn't always work.

I suspect that typically the crash happens when the user stack runs out
(which we can't detect portably, indeed it's hard enough to detect at
all as this is usually hidden from user-level code).  It would be
possible to store more function frame information in other forms of
memory which are much less likely to run out.  Unfortunately, while
things like this could help they are just moving the problem around a
bit and are quite hard to test widely enough to know if they're even
making an improvement.


Messages sorted by: Reverse Date, Date, Thread, Author