zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: Re: zsh dumps core on ssh <TAB><C-c><C-c><C-d>
Date: Mon, 29 Nov 1999 10:10:05 +0100 (MET)	[thread overview]
Message-ID: <199911290910.KAA23170@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: Tanaka Akira's message of 27 Nov 1999 01:12:45 +0900


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 <TAB><C-c><C-c>
> is27e1u11% <C-d>
> 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


             reply	other threads:[~1999-11-29  9:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-11-29  9:10 Sven Wischnowsky [this message]
  -- strict thread matches above, loose matches on Subject: below --
1999-11-26 16:12 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=199911290910.KAA23170@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).