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

Re: zsh glitch

On Tue, Nov 10, 2015 at 10:36 PM, Lane Erickson <lerickson@xxxxxxxxxxxx> wrote:
> http://stackoverflow.com/questions/33639879/strange-zsh-segfault-glitch-with-function-definitions

Please post the actual question to the mailing list. In 20 years when
someone reads this in the archive, stackoverflow might not exist
anymore ;).

> Does anyone know why this behavior exists in zsh, or what zsh is trying to do that causes a segfault?
> ➜  ~  (echo "hi"(); echo "hi"; echo "hi")
> [1]    65962 segmentation fault  ( echo "hi" () { ... }; echo "hi"; )
> ➜  ~  (ls(); ls; ls)
> [1]    66073 segmentation fault  ( ls -G () { ... }; ls -G; )

If it segfaults here, it's either because you're running an old
version or the compiler miscompiled, or the zsh code disagrees with
the compiler about what can be optimized out. What should happen is
the following:

% (ls(); ls; ls)
ls:1: maximum nested function level reached

What you've done is define a function that looks like this
ls() {
and then you call it, which causes an infinite recursion. This usually
does not end well in any language.

Mikael Magnusson

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