zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: Zsh Hackers' List <zsh-workers@zsh.org>
Cc: Oliver Kiddle <okiddle@yahoo.co.uk>
Subject: Re: Crash when completion script call itself.
Date: Tue, 03 Oct 2017 16:50:12 +0100	[thread overview]
Message-ID: <20171003165012.4407c37c@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <9379.1507044225@thecus.kiddle.eu>

On Tue, 03 Oct 2017 17:23:45 +0200
Oliver Kiddle <okiddle@yahoo.co.uk> wrote:
> I still have issues with posting to the mailing list (tends to take
> several resends) so I've not bothered...
> 
> You wrote:
> > This looks like low-hanging fruit.  Allocating memory to save over a
> > shell function happens just at the point where we've created the new
> > heap for the function, which expires immediately after the call.  The
> 
> I'm not sure what you mean by "save over a shell function"? Do I
> understand this as just using the heap instead of the stack for whatever
> needs to be saved for each nested function? Is that so that we can
> detect the eventual out-of-memory condition and can report it or to try
> to maximise the possible number of recursions? Either way, it could do
> with a comment to make the purpose clear.

It's just to minimise stack usage.  The fact the data is going somewhere
other than the stack doesn't obviously need a comment, but I'll note the
change in case someone sees odd effects and starts looking for a cause.

If someone finds pathological behaviour with this, it's not a huge gain
anyway so could be abandoned.

> I'd have thought we could compress the data somewhat. In particular the
> opts array must be around 200 bytes. That could be divided by eight with
> bit fields or reduced near to nothing for functions that don't do setopt
> localoptions.

That's definitely going to impact on the time taken.  If someone wants
to start looking at real trade-offs of this sort they're welcome, but
I'm not going anywhere near this.  200 bytes over 1000 functions is not
huge by the standards of modern PC non-stack memory (I've taken off my
embedded programming hat which is quite tightly fitting anyway...).

> I also wonder if funcsave might be combined with funcstack
> somehow: are both a stack of function calls?

funcstack and funcsave are there for rather different purposes.
funcstack is exposed to give a user-visible state; it's not necessarily
constrained to grow or shrink within execshfunc().  funcsave is the
dirty washing inside execshfunc() there's no obvious reason to expose.

pws


  parent reply	other threads:[~2017-10-03 15:58 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20170929072715epcas1p4171c28e9b82f94d79796ecca7e564ec3@epcas1p4.samsung.com>
2017-09-29  7:25 ` Nicolas Desprès
2017-09-29  9:34   ` Peter Stephenson
2017-09-29 10:30     ` Nicolas Desprès
2017-09-29 10:40       ` Peter Stephenson
2017-09-29 10:45         ` Peter Stephenson
2017-09-29 11:03           ` Nicolas Desprès
2017-09-29 11:10             ` Peter Stephenson
2017-09-29 11:27               ` Kamil Dudka
2017-09-29 14:16                 ` Peter Stephenson
2017-09-29 15:22                   ` Bart Schaefer
2017-09-29 15:36                     ` Peter Stephenson
2017-09-29 17:48                       ` Bart Schaefer
2017-10-02 15:40                   ` Peter Stephenson
2017-10-03 14:45                     ` Kamil Dudka
2017-10-03 17:55                       ` Mikael Magnusson
2017-10-04  8:20                         ` Peter Stephenson
     [not found]                     ` <9379.1507044225@thecus.kiddle.eu>
2017-10-03 15:50                       ` Peter Stephenson [this message]
2017-09-29 23:00                 ` Nicolas Desprès
2017-09-29 11:38               ` Nicolas Desprès
2017-09-29 11:37         ` Martijn Dekker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171003165012.4407c37c@pwslap01u.europe.root.pri \
    --to=p.stephenson@samsung.com \
    --cc=okiddle@yahoo.co.uk \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).