Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: core dump by completion.
- X-seq: zsh-workers 9618
- From: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: Re: core dump by completion.
- Date: Tue, 8 Feb 2000 12:32:21 +0100 (MET)
- In-reply-to: Tanaka Akira's message of 07 Feb 2000 23:10:31 +0900
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
Tanaka and I had a bit of a private discussion, trying to find
the memory bug he mentioned. He found a way to reproduce it:
> ...
>
> I couldn't remember. But finally I found a reproducible way to dump core.
>
> Z(2):akr@is27e1u11% Src/zsh -f
> is27e1u11% bindkey -e; autoload -U compinit; compinit -D; compdef _tst tst
> is27e1u11% _tst () { _arguments -a ":desc1:(arg1)" "*::desc2:_tst2" }
> is27e1u11% _tst2 () { _arguments "*:de:($CURRENT)" }
> is27e1u11% tst -a <TAB><TAB><TAB><TAB><TAB><TAB><TAB><TAB><TAB><TAB>
> ->
> is27e1u11% tst -a arg1 2 3 4 5 6 7 8 9 zsh: bus error (core dumped) Src/zsh -f
When the cache of parsed _argument descriptions was full and a new one
was added and that one happened to be the one just used, a bit of
information needed by the next invocation of ca_parse_line() was
overwritten: it didn't know the correct number of options anymore.
Of course, the cache entry for the definitions that were just used
shouldn't be used for the next set of definitions. And get_cadef()
tried to avoid that -- failing to do so because of a rather stupid
off-by-one error.
Thanks, Tanaka.
Bye
Sven
diff -ru ../z.old/Src/Zle/computil.c Src/Zle/computil.c
--- ../z.old/Src/Zle/computil.c Tue Feb 8 11:07:54 2000
+++ Src/Zle/computil.c Tue Feb 8 11:47:25 2000
@@ -875,7 +875,7 @@
Cadef *p, *min, new;
int i, na = arrlen(args);
- for (i = MAX_CACACHE, p = cadef_cache, min = NULL; *p && i--; p++)
+ for (i = MAX_CACACHE, p = cadef_cache, min = NULL; *p && i; p++, i--)
if (*p && na == (*p)->ndefs && arrcmp(args, (*p)->defs)) {
(*p)->lastt = time(0);
@@ -1003,6 +1003,7 @@
struct castate {
Cadef d;
+ int nopts;
Caarg def, ddef;
Caopt curopt;
int opt, arg, argbeg, optbeg, nargbeg, restbeg;
@@ -1029,7 +1030,7 @@
/* Free old state. */
if (ca_alloced) {
- int i = ca_laststate.d->nopts;
+ int i = ca_laststate.nopts;
LinkList *p = ca_laststate.oargs;
freelinklist(ca_laststate.args, freestr);
@@ -1048,6 +1049,7 @@
/* Default values for the state. */
state.d = d;
+ state.nopts = d->nopts;
state.def = state.ddef = NULL;
state.curopt = NULL;
state.argbeg = state.optbeg = state.nargbeg = state.restbeg =
--
Sven Wischnowsky wischnow@xxxxxxxxxxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author