zsh-workers
 help / color / mirror / code / Atom feed
* zsh glitch
@ 2015-11-10 21:36 Lane Erickson
  2015-11-10 21:43 ` Mikael Magnusson
  0 siblings, 1 reply; 4+ messages in thread
From: Lane Erickson @ 2015-11-10 21:36 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 98 bytes --]

http://stackoverflow.com/questions/33639879/strange-zsh-segfault-glitch-with-function-definitions

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: zsh glitch
  2015-11-10 21:36 zsh glitch Lane Erickson
@ 2015-11-10 21:43 ` Mikael Magnusson
  2015-11-11  9:36   ` Peter Stephenson
  2015-11-12 15:48   ` Christian Neukirchen
  0 siblings, 2 replies; 4+ messages in thread
From: Mikael Magnusson @ 2015-11-10 21:43 UTC (permalink / raw)
  To: Lane Erickson; +Cc: zsh workers

On Tue, Nov 10, 2015 at 10:36 PM, Lane Erickson <lerickson@liveramp.com> 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() {
  ls
}
and then you call it, which causes an infinite recursion. This usually
does not end well in any language.

-- 
Mikael Magnusson


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: zsh glitch
  2015-11-10 21:43 ` Mikael Magnusson
@ 2015-11-11  9:36   ` Peter Stephenson
  2015-11-12 15:48   ` Christian Neukirchen
  1 sibling, 0 replies; 4+ messages in thread
From: Peter Stephenson @ 2015-11-11  9:36 UTC (permalink / raw)
  To: zsh workers

On Tue, 10 Nov 2015 22:43:20 +0100
Mikael Magnusson <mikachu@gmail.com> wrote:
> 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

It's basically luck whether you hit the maximum recursion depth before
you run out of stack (and hence crash) or not.  There's no easy way for
the shell to tell when this is going to happen, so it's very system
dependent.

The only better way out I can see is for someone with a wider knowledge
of the sort of systems they're compiling zsh for to attempt a more
appropriate configuration with --enable-max-function-depth=MAX.
The default is 1000; a nice round number that works in a lot of places
is about the best we can do generally.  For general purpose Linux
distributions I suspect that statement continues to apply.

pws


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: zsh glitch
  2015-11-10 21:43 ` Mikael Magnusson
  2015-11-11  9:36   ` Peter Stephenson
@ 2015-11-12 15:48   ` Christian Neukirchen
  1 sibling, 0 replies; 4+ messages in thread
From: Christian Neukirchen @ 2015-11-12 15:48 UTC (permalink / raw)
  To: zsh-workers

Mikael Magnusson <mikachu@gmail.com> writes:

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

Time to add tail-recursion to zsh!

-- 
Christian Neukirchen  <chneukirchen@gmail.com>  http://chneukirchen.org


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-11-12 15:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-10 21:36 zsh glitch Lane Erickson
2015-11-10 21:43 ` Mikael Magnusson
2015-11-11  9:36   ` Peter Stephenson
2015-11-12 15:48   ` Christian Neukirchen

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).