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

Re: segfault in tab-completion menu if terminal is only one line tall



On Jan 18,  1:37am, Axel Beckert wrote:
}
} 1. Open terminal emulator
} 
} 2. Resize window so that there's only one line for the shell (i.e.
} where the prompt also is).
} 
} 3. Enter: ls <tab><tab> (that is, begin typing the 'ls' command, then
} press tabulator twice to tab complete.)

I was able to reproduce if I start zsh in an 80x1 terminal emulator, but
not after resizing a larger terminal where zsh is already running down
to 1 line.  Possibly something is getting initialized differently in the
two cases.

Other strange things happen if I size the window down to 1 line, try a
completion, and then stretch back to a larger size again; e.g., repainting
the prompt above the select menu doesn't work properly.

} zstyle ':completion:*' menu select=long-list select=0
} zstyle ':completion:*' select-prompt '%SScrolling active - %l%s'

Yes, those are necessary (or at least the first one is) because the crash
occurs in the zsh/complist module which is used for "menu select=long".

The following patch stops the crash I was able to reproduce, but there
may be other ways to tickle it in different circumstances.  This might
also fix the prompt redisplay problem I mentioned above, but I'm not
confident of my steps to reproduce that one.


diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index bcf3561..b852ee9 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -2500,7 +2500,7 @@ domenuselect(Hookdef dummy, Chdata dat)
 		mlbeg--;
 	    }
 	}
-	if ((space = zterm_lines - pl - mhasstat))
+	if ((space = zterm_lines - pl - mhasstat) > 0)
 	    while (mline >= mlbeg + space)
 		if ((mlbeg += step) + space > mlines)
 		    mlbeg = mlines - space;

-- 
Barton E. Schaefer



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