Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: menu-select crashes and redraw problems



On Sun, 23 Dec 2007 07:24:48 +0100
"Mikael Magnusson" <mikachu@xxxxxxxxx> wrote:
> When i use menu-select and resize the terminal while the select is
> going on (no, I don't usually do this :) ), zsh usually crashes after
> a couple of tries. It almost always messes up the display of the list
> after a resize, sometimes it fixes itself when you scroll around,
> sometimes not. I reproduced it with zsh -f like this
> 
> zsh -f
> zmodload zsh/complist
> ls <alt-x>menu-select<enter>
> <scroll around a bit, preferably to a second or higher column>*
> <resize terminal narrower so the column with the cursor disappears>
> <scroll around a bit more>
> <repeat from * until zsh crashes>

After an hour or two chasing red herrings around gum trees, I came up
with this.  It's not the end of the story, since the display seems to
get messed up occasionally, but it does seem to reduce or possibly
eliminate crashes.  This is one of those "please don't ask me what it
does" fixes, but I think the story is cases like this are mostly handled
and it simply didn't try quite as hard as it could to fix up lines and
columns.

I suspect that in principle there are horrific races such that if
SIGWINCH arrives when the code is anywhere other than waiting for a key
press pretty much anything can happen.  I am successfully ignoring this
so far and hope to continue doing so.

As you'll see in the first hunk, I've added a detailed explanatory
comment to one of the many sophisticated features of the code.

Index: Src/Zle/complist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/complist.c,v
retrieving revision 1.107
diff -u -r1.107 complist.c
--- Src/Zle/complist.c	15 Feb 2008 22:01:05 -0000	1.107
+++ Src/Zle/complist.c	28 Feb 2008 22:51:40 -0000
@@ -122,7 +122,11 @@
 int mgtabsize;
 #endif
 
-/* Used in mtab/mgtab, for explanations. */
+/*
+ * Used in mtab/mgtab, for explanations.
+ *
+ * UUUUUUUUUUUUUUURRRRGHHHHHHHHHH!!!!!!!!! --- pws
+ */
 
 #define MMARK       ((unsigned long) 1)
 #define mmarked(v)  (((unsigned long) (v)) & MMARK)
@@ -2325,8 +2329,7 @@
     for (;;) {
 	METACHECK();
 
-    	mtab_been_reallocated = 0;
-	if (mline < 0) {
+	if (mline < 0 || mtab_been_reallocated) {
 	    int x, y;
 	    Cmatch **p = mtab;
 
@@ -2342,6 +2345,7 @@
 	    if (y < mlines)
 		mline = y;
 	}
+    	mtab_been_reallocated = 0;
 	DPUTS(mline < 0,
 	      "BUG: mline < 0 after re-scanning mtab in domenuselect()");
 	while (mline < mlbeg)


-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/



Messages sorted by: Reverse Date, Date, Thread, Author