From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22214 invoked from network); 10 Mar 2005 16:56:11 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 10 Mar 2005 16:56:11 -0000 Received: (qmail 93648 invoked from network); 10 Mar 2005 16:56:06 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 10 Mar 2005 16:56:06 -0000 Received: (qmail 25839 invoked by alias); 10 Mar 2005 16:56:04 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 20958 Received: (qmail 25830 invoked from network); 10 Mar 2005 16:56:03 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 10 Mar 2005 16:56:03 -0000 Received: (qmail 93307 invoked from network); 10 Mar 2005 16:56:00 -0000 Received: from vms046pub.verizon.net (206.46.252.46) by a.mx.sunsite.dk with SMTP; 10 Mar 2005 16:55:56 -0000 Received: from candle.brasslantern.com ([4.11.1.68]) by vms046.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix 0.04 (built Dec 24 2004)) with ESMTPA id <0ID500BSZB16LQH0@vms046.mailsrvcs.net> for zsh-workers@sunsite.dk; Thu, 10 Mar 2005 10:55:55 -0600 (CST) Received: from candle.brasslantern.com (IDENT:schaefer@localhost [127.0.0.1]) by candle.brasslantern.com (8.12.11/8.12.11) with ESMTP id j2AGtq79005102 for ; Thu, 10 Mar 2005 08:55:53 -0800 Received: (from schaefer@localhost) by candle.brasslantern.com (8.12.11/8.12.11/Submit) id j2AGtqPa005101 for zsh-workers@sunsite.dk; Thu, 10 Mar 2005 08:55:52 -0800 Date: Thu, 10 Mar 2005 16:55:52 +0000 From: Bart Schaefer Subject: PATCH: Re: Segfault on "zmodload -u zsh/parameter" In-reply-to: <1050305181810.ZM1556@candle.brasslantern.com> To: zsh-workers@sunsite.dk Message-id: <1050310165552.ZM5100@candle.brasslantern.com> MIME-version: 1.0 X-Mailer: Z-Mail (5.0.0 30July97) Content-type: text/plain; charset=us-ascii References: <1050305181810.ZM1556@candle.brasslantern.com> Comments: In reply to Bart Schaefer "Segfault on "zmodload -u zsh/parameter"" (Mar 5, 6:18pm) X-Spam-Checker-Version: SpamAssassin 3.0.2 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, score=-2.6 required=6.0 tests=BAYES_00 autolearn=ham version=3.0.2 X-Spam-Hits: -2.6 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 =