From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16717 invoked from network); 29 Nov 1999 09:10:36 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 29 Nov 1999 09:10:36 -0000 Received: (qmail 10304 invoked by alias); 29 Nov 1999 09:10:11 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8796 Received: (qmail 10232 invoked from network); 29 Nov 1999 09:10:10 -0000 Date: Mon, 29 Nov 1999 10:10:05 +0100 (MET) Message-Id: <199911290910.KAA23170@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk In-reply-to: Tanaka Akira's message of 27 Nov 1999 01:12:45 +0900 Subject: Re: zsh dumps core on ssh Tanaka Akira wrote: > zsh dumps core as follows: > > Z(2):akr@is27e1u11% Src/zsh -f > is27e1u11% bindkey -e; fpath=($PWD/Completion/*(/)); autoload -U compinit; compinit -D; compdef _tst tst > is27e1u11% ssh > is27e1u11% > zsh: segmentation fault (core dumped) Src/zsh -f > Z(2):akr@is27e1u11% gdb Src/zsh core > ... > #0 0x9ed24 in freearray (s=0x0) at utils.c:2192 > 2192 while (*s) I sometimes forget that freearray() can't savely be called with a NULL pointer -- contrary to the other freeing functions. This makes it saver, even adding a DPUTS() to freearray(). The interesting bit is that this was triggered by the module patch that made the cleanup functions of all modules be called at the end. Without that we probably wouldn't have found this bug. Bye Sven diff -u -r oldsrc/Zle/computil.c Src/Zle/computil.c --- oldsrc/Zle/computil.c Fri Nov 26 09:53:32 1999 +++ Src/Zle/computil.c Mon Nov 29 10:03:05 1999 @@ -451,13 +451,15 @@ Caopt p, n; zsfree(d->match); - freearray(d->defs); + if (d->defs) + freearray(d->defs); for (p = d->opts; p; p = n) { n = p->next; zsfree(p->name); zsfree(p->descr); - freearray(p->xor); + if (p->xor) + freearray(p->xor); freecaargs(p->args); zfree(p, sizeof(*p)); } @@ -1592,13 +1594,15 @@ Cvval p, n; zsfree(d->descr); - freearray(d->defs); + if (d->defs) + freearray(d->defs); for (p = d->vals; p; p = n) { n = p->next; zsfree(p->name); zsfree(p->descr); - freearray(p->xor); + if (p->xor) + freearray(p->xor); freecaargs(p->arg); zfree(p, sizeof(*p)); } @@ -2211,7 +2215,8 @@ n = s->next; zsfree(s->name); - freearray(s->vals); + if (s->vals) + freearray(s->vals); zfree(s, sizeof(*s)); s = n; @@ -2274,7 +2279,8 @@ /* Exists -> replace. */ - freearray(s->vals); + if (s->vals) + freearray(s->vals); PERMALLOC { s->vals = arrdup(vals); } LASTALLOC; @@ -2616,7 +2622,8 @@ while (s) { n = s->next; - freearray(s->tags); + if (s->tags) + freearray(s->tags); zfree(s, sizeof(*s)); s = n; @@ -2627,7 +2634,8 @@ freectags(Ctags t) { if (t) { - freearray(t->all); + if (t->all) + freearray(t->all); zsfree(t->context); freectset(t->sets); zfree(t, sizeof(*t)); diff -u -r oldsrc/utils.c Src/utils.c --- oldsrc/utils.c Fri Nov 26 09:53:30 1999 +++ Src/utils.c Mon Nov 29 10:04:09 1999 @@ -2189,6 +2189,8 @@ { char **t = s; + DPUTS(!s, "freearray() with zero argument"); + while (*s) zsfree(*s++); free(t); -- Sven Wischnowsky wischnow@informatik.hu-berlin.de