zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@sunsite.dk
Subject: PATCH: Re: Segfault on "zmodload -u zsh/parameter"
Date: Thu, 10 Mar 2005 16:55:52 +0000	[thread overview]
Message-ID: <1050310165552.ZM5100@candle.brasslantern.com> (raw)
In-Reply-To: <1050305181810.ZM1556@candle.brasslantern.com>

On Mar 5,  6:18pm, Bart Schaefer wrote:
} Subject: Segfault on "zmodload -u zsh/parameter"
}
} Latest CVS.  Appears to happen when unsetting the "parameters" parameter.

I would have thought this attracted a little more attention.

Anyway, the problem is this:

/**/
mod_export const struct gsu_hash nullsethash_gsu =
{ hashgetfn, nullsethashfn, NULL };

unsetparam_pm() unconditionally calls pm->gsu.s->unsetfn(), but in that
structure (which is duplicated in Src/params.c and Modules/parameter.c
for obscure reasons) the unsetfn is NULL, and boom.

A grep shows that the "parameters" parameter is apparently the only one
that uses this particular structure.

A lot of parameters are using this one:

/**/
mod_export const struct gsu_scalar nullsetscalar_gsu =
{ strgetfn, nullstrsetfn, NULL };

And the zsh/term* modules use:

/**/
mod_export const struct gsu_integer nullsetinteger_gsu =
{ intgetfn, NULL, NULL };

But apparently those are only used for the internal elements of hashes,
and therefore they're not called even when the hashes themselves are
unset.

Thus it doesn't seem desirable to test for null-ness of s->unsetfn in
unsetparam_pm(), but it's also unsuitable to put either nullstrsetfn
or nullintsetfn in that slot.  Hence the patch below.

Other mutterings:

Should nullnullsetfn be used in other places instead of NULL, too?

Why do we have nullstrsetfn and nullintsetfn but nullsethashfn?


Index: Src/params.c
===================================================================
RCS file: /extra/cvsroot/zsh/zsh-4.0/Src/params.c,v
retrieving revision 1.28
diff -c -r1.28 params.c
--- Src/params.c	18 Feb 2005 17:05:17 -0000	1.28
+++ Src/params.c	10 Mar 2005 16:45:52 -0000
@@ -147,7 +147,7 @@
 { hashgetfn, hashsetfn, stdunsetfn };
 /**/
 mod_export const struct gsu_hash nullsethash_gsu =
-{ hashgetfn, nullsethashfn, NULL };
+{ hashgetfn, nullsethashfn, nullnullsetfn };
 
 
 /* Non standard methods (not exported) */
@@ -2604,6 +2604,10 @@
 /**/
 void
 nullintsetfn(UNUSED(Param pm), UNUSED(zlong x))
+{}
+
+/**/
+nullnullsetfn(UNUSED(Param pm), UNUSED(int exp))
 {}
 
 
Index: Src/Modules/parameter.c
===================================================================
RCS file: /extra/cvsroot/zsh/zsh-4.0/Src/Modules/parameter.c,v
retrieving revision 1.11
diff -c -r1.11 parameter.c
--- Src/Modules/parameter.c	18 Feb 2005 17:05:18 -0000	1.11
+++ Src/Modules/parameter.c	10 Mar 2005 16:45:42 -0000
@@ -1817,7 +1817,7 @@
  * in a compile-time initialiser, so we use this instead.
  */
 static const struct gsu_hash pmnullsethash_gsu =
-{ hashgetfn, nullsethashfn, NULL };
+{ hashgetfn, nullsethashfn, nullnullsetfn };
 static const struct gsu_hash pmcommands_gsu =
 { hashgetfn, setpmcommands, stdunsetfn };
 static const struct gsu_hash pmfunctions_gsu =


  parent reply	other threads:[~2005-03-10 16:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-05 18:18 Bart Schaefer
2005-03-06  5:09 ` Bart Schaefer
2005-03-10 16:55 ` Bart Schaefer [this message]
2005-03-10 17:32   ` PATCH: " Peter Stephenson
2005-03-10 18:04     ` Bart Schaefer

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=1050310165552.ZM5100@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@sunsite.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).