zsh-workers
 help / color / mirror / code / Atom feed
* r in completion function causes zsh abort
@ 2012-11-08 10:25 Oliver Kiddle
  2012-11-08 15:15 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Oliver Kiddle @ 2012-11-08 10:25 UTC (permalink / raw)
  To: Zsh workers

After accidentally leaving a spurious `r' in a completion function, zsh
crashes with:

*** glibc detected *** zsh: double free or corruption (fasttop): 0x00000000022bc640 ***

It doesn't seem to occur directly from zsh -f but attempting to bisect
my options makes me suspect that there isn't a specific set that are
needed. Anyway, the following appears to reliably reproduce the problem:

zsh -f
autoload -U compinit;compinit
compdef r ty
setopt -09hwE
ty <tab>

Oliver


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

* Re: r in completion function causes zsh abort
  2012-11-08 10:25 r in completion function causes zsh abort Oliver Kiddle
@ 2012-11-08 15:15 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2012-11-08 15:15 UTC (permalink / raw)
  To: Zsh workers

On Nov 8, 11:25am, Oliver Kiddle wrote:
}
} After accidentally leaving a spurious `r' in a completion function, zsh
} crashes

"r" will of course attempt to invoke command history; it's not surprising
that doing so down in the guts of a completion function dives into some
code that's not prepared to be called at that juncture.

Sure enough, the stack trace is

abort
free
hend
loop
bin_fc
execbuiltin

(Don't have debugging compiled on the machine where I'm able to test this
right now.)  There's no way bin_fc should be calling the main loop during
completion, and probably not at any time while zle is active (which is a
lot easier to test).

Feel free to suggest a better error message ...

Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.267
diff -u -r1.267 builtin.c
--- Src/builtin.c       11 Oct 2012 20:14:03 -0000      1.267
+++ Src/builtin.c       8 Nov 2012 15:14:41 -0000
@@ -1414,6 +1414,12 @@
        unqueue_signals();
        return 0;
     }
+
+    if (zleactive) {
+       zwarnnam(nam, "no interactive history within ZLE");
+       return 1;
+    }
+
     /* put foo=bar type arguments into the substitution list */
     while (*argv && equalsplit(*argv, &s)) {
        Asgment a = (Asgment) zhalloc(sizeof *a);


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

end of thread, other threads:[~2012-11-08 15:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-08 10:25 r in completion function causes zsh abort Oliver Kiddle
2012-11-08 15:15 ` Bart Schaefer

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).