zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: workers/40626 (commit 6c476c22) causes multiple test failures
Date: Sun, 26 Feb 2017 11:42:16 -0800	[thread overview]
Message-ID: <170226114216.ZM4201@torch.brasslantern.com> (raw)
In-Reply-To: <20170226061620.GA3729@fujitsu.shahaf.local2>

On Feb 26,  6:16am, Daniel Shahaf wrote:
} Subject: Re: workers/40626 (commit 6c476c22) causes multiple test failures
}
} Bart Schaefer wrote on Sat, Feb 25, 2017 at 16:04:55 -0800:
} > This is just the first one that dies:
} 
} I could swear 'make check' had passed before I pushed this, but I can
} reproduce this.  No time to debug, so reverted.  Sorry for the breakage.

workers/40508 always seemed questionable to me.

I suspect this is what comes of some attempt to optimize assignments.
There may be cases where the recopy operation in these set*() functions
is redundant, but I don't feel like tracking that down just now; it is
definitely necessary for $options, so ...


diff --git a/Src/Modules/parameter.c b/Src/Modules/parameter.c
index c251e4f..10c47d2 100644
--- a/Src/Modules/parameter.c
+++ b/Src/Modules/parameter.c
@@ -167,7 +167,7 @@ unsetpmcommand(Param pm, UNUSED(int exp))
 
 /**/
 static void
-setpmcommands(UNUSED(Param pm), HashTable ht)
+setpmcommands(Param pm, HashTable ht)
 {
     int i;
     HashNode hn;
@@ -190,7 +190,15 @@ setpmcommands(UNUSED(Param pm), HashTable ht)
 
 	    cmdnamtab->addnode(cmdnamtab, ztrdup(hn->nam), &cn->node);
 	}
-    deleteparamtable(ht);
+    /*
+     * On full-array assignment ht is a temporary hash with the default
+     * get/set functions, whereas pm->u.hash has the special $commands
+     * get/set functions.  Do not assign ht to pm, just delete it.
+     *
+     * On append, ht and pm->u.hash are the same table, don't delete.
+     */
+    if (ht != pm->u.hash)
+	deleteparamtable(ht);
 }
 
 static const struct gsu_scalar pmcommand_gsu =
@@ -349,7 +357,9 @@ setfunctions(Param pm, HashTable ht, int dis)
 
 	    setfunction(hn->nam, ztrdup(getstrvalue(&v)), dis);
 	}
-    hashsetfn(pm, ht);
+    /* See setpmcommands() above */
+    if (ht != pm->u.hash)
+	deleteparamtable(ht);
 }
 
 /**/
@@ -937,7 +947,7 @@ unsetpmoption(Param pm, UNUSED(int exp))
 
 /**/
 static void
-setpmoptions(UNUSED(Param pm), HashTable ht)
+setpmoptions(Param pm, HashTable ht)
 {
     int i;
     HashNode hn;
@@ -962,7 +972,9 @@ setpmoptions(UNUSED(Param pm), HashTable ht)
 			      (val && strcmp(val, "off")), 0, opts))
 		zwarn("can't change option: %s", hn->nam);
 	}
-    deleteparamtable(ht);
+    /* See setpmcommands() above */
+    if (ht != pm->u.hash)
+	deleteparamtable(ht);
 }
 
 static const struct gsu_scalar pmoption_gsu =
@@ -1501,7 +1513,7 @@ unsetpmnameddir(Param pm, UNUSED(int exp))
 
 /**/
 static void
-setpmnameddirs(UNUSED(Param pm), HashTable ht)
+setpmnameddirs(Param pm, HashTable ht)
 {
     int i;
     HashNode hn, next, hd;
@@ -1543,7 +1555,9 @@ setpmnameddirs(UNUSED(Param pm), HashTable ht)
 
     i = opts[INTERACTIVE];
     opts[INTERACTIVE] = 0;
-    deleteparamtable(ht);
+    /* See setpmcommands() above */
+    if (ht != pm->u.hash)
+	deleteparamtable(ht);
     opts[INTERACTIVE] = i;
 }
 
@@ -1724,7 +1738,7 @@ unsetpmsalias(Param pm, UNUSED(int exp))
 
 /**/
 static void
-setaliases(HashTable alht, UNUSED(Param pm), HashTable ht, int flags)
+setaliases(HashTable alht, Param pm, HashTable ht, int flags)
 {
     int i;
     HashNode hn, next, hd;
@@ -1760,7 +1774,9 @@ setaliases(HashTable alht, UNUSED(Param pm), HashTable ht, int flags)
 		alht->addnode(alht, ztrdup(hn->nam),
 			      createaliasnode(ztrdup(val), flags));
 	}
-    deleteparamtable(ht);
+    /* See setpmcommands() above */
+    if (ht != pm->u.hash)
+	deleteparamtable(ht);
 }
 
 /**/


  reply	other threads:[~2017-02-26 19:42 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-26  0:04 Bart Schaefer
2017-02-26  6:16 ` Daniel Shahaf
2017-02-26 19:42   ` Bart Schaefer [this message]
2017-02-27  9:31     ` Sebastian Gniazdowski
2017-02-28  7:45     ` Daniel Shahaf
2017-02-28 16:38       ` Bart Schaefer
2017-02-28 17:03         ` Daniel Shahaf
2017-02-28 19:04           ` Bart Schaefer
2017-02-28 21:51             ` Daniel Shahaf
2017-03-01 15:55               ` Bart Schaefer
2017-02-27  9:41 Sebastian Gniazdowski
2017-02-27 16:42 ` Bart Schaefer
2017-02-27 18:48   ` Sebastian Gniazdowski
2017-02-27 20:08     ` Daniel Shahaf
2017-02-27 20:38       ` Frank Terbeck

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=170226114216.ZM4201@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /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).