zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: "Zsh Hackers' List" <zsh-workers@zsh.org>
Subject: Re: Crash when capturing command output in completion
Date: Thu, 15 Jan 2015 20:43:36 -0800	[thread overview]
Message-ID: <150115204336.ZM23779@torch.brasslantern.com> (raw)
In-Reply-To: <CACeGjnWw2m5KoZ7EX2u1SoSmNWPVEVUSQsSt4WF4vw3UQ_f7Mw@mail.gmail.com>

On Jan 15, 10:17pm, Vin Shelton wrote:
}
} echo $(installed_packages)<TAB>
} 
} results in the crash.

OK, I can pretty trivially reproduce this, but what I get is:

schaefer<501> echo $(ls)
zsh: fatal error: out of memory

742                 compisuffix = (char *) zalloc((l = parwe - we) + 1);
(gdb) p parwe
$1 = 10
(gdb) p we
$2 = 12

So this ends up calling zcalloc(-1), and kapow.

"we" becomes 12 at compcore.c line 1261 in this block:

	    /* And adjust wb, we, and offs again. */
	    offs -= b - s;
	    wb = zlemetacs - offs;
	    we = wb + e - b;
	    ispar = (br >= 2 ? 2 : 1);
	    b[we-wb] = '\0';
	    return b;

We come into that block at line 1219 like this:

(gdb) p offs
$11 = 1
(gdb) p e
$12 = 0x818263 "\211x"
(gdb) p s
$13 = 0x818260 "\205ls\211x"
(gdb) p b
$14 = 0x818261 "ls\211x"
(gdb) p s
$15 = 0x818260 "\205ls\211x"
(gdb) p zlemetacs
$16 = 10
(gdb) p wb
$17 = 9
(gdb) p we
$18 = 10
(gdb) p br
$19 = 1

Neither "test" nor "set" is true, so we enter "if (compfunc)" at line
1251 to /* Save the prefix. */  This does nothing but assign "$" to
parpre, so the initial state of all those variables is unchanged by
the time we start to "adjust" them.

I'm not sure what's supposed to happen at this point.  None of these
values seem to line up with where the "adjustments" expect them.  I
suspect we've accidentally attempted to treat "(ls)" as a parameter
name.

The only recent change in compcore.c is lexsave() -> zcontext_save();
the last thing to actually touch this function was parameter modifier
handling, which is a different [new] branch of the same if/else and
happens independent of the branch causing this error.


  reply	other threads:[~2015-01-16  4:43 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-15 19:34 Vin Shelton
2015-01-15 21:53 ` Bart Schaefer
2015-01-15 23:53   ` Vin Shelton
2015-01-16  0:27     ` Bart Schaefer
2015-01-16  3:11       ` Vin Shelton
2015-01-16  3:17         ` Vin Shelton
2015-01-16  4:43           ` Bart Schaefer [this message]
2015-01-16  5:20             ` Bart Schaefer
2015-01-16  9:44               ` Peter Stephenson
2015-01-16 12:57                 ` Peter Stephenson
2015-01-16 16:18                   ` Bart Schaefer
2015-01-16 16:25                     ` Bart Schaefer
2015-01-16 18:04                     ` Peter Stephenson
2015-01-16 18:58                       ` Bart Schaefer
2015-01-16 19:16                         ` Bart Schaefer
2015-01-16 20:05                           ` Peter Stephenson
2015-01-16 19:19                         ` Ray Andrews
2015-01-16  6:43             ` Ray Andrews
2015-01-16  7:49               ` Bart Schaefer
2015-01-16 16:21                 ` Ray Andrews
2015-01-16 16:34                   ` Bart Schaefer

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=150115204336.ZM23779@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --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).