From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: Re: core dump by completion.
Date: Tue, 8 Feb 2000 12:32:21 +0100 (MET) [thread overview]
Message-ID: <200002081132.MAA02054@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: Tanaka Akira's message of 07 Feb 2000 23:10:31 +0900
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@informatik.hu-berlin.de
next reply other threads:[~2000-02-08 11:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-02-08 11:32 Sven Wischnowsky [this message]
-- strict thread matches above, loose matches on Subject: below --
2000-02-04 15:07 Sven Wischnowsky
2000-02-04 15:45 ` Tanaka Akira
2000-02-04 13:52 Tanaka Akira
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=200002081132.MAA02054@beta.informatik.hu-berlin.de \
--to=wischnow@informatik.hu-berlin.de \
--cc=zsh-workers@sunsite.auc.dk \
/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).