[Pkg-zsh-devel] Bug#353863: Bugreport: completion hanging at ubo<Tab> - endless loop

Peter Stephenson p.w.stephenson at ntlworld.com
Wed Feb 23 11:30:04 UTC 2011


On Wed, 23 Feb 2011 11:50:18 +0100
Michael Prokop <news at michael-prokop.at> wrote:
> in http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=353863
> Sebastien Desreux reported a bug about zsh with its
> completion system in a specific situation.
> 
> To trigger the bug (at least 4.3.10 and 4.3.11 in Debian are
> known to be affected by this bug):
> 
>   zsh -f
>   autoload -Uz compinit; compinit; alias ubox=ls
>   ubo<tab>
> 
> Then the zsh process is hanging in an endless loop, eating CPU.

Tee hee.  This is what happens when your interface between the
completion system and the main shell is a complete hack.

If the option COMPLETE_ALIASES is off, the shell tries to expand
aliases, so it can do completion for aliased commands without the
completion system needing to understand the alias.

To analyse a command line to find the current context, completion adds
an "x" at the cursor position which it later removes.  In this case, the
"x" completes the word "ubox", which is then expanded to "ls".  The
completion system doesn't notice and assumes it still has the original
command line.  It removes the non-existent "x" to get "l" which it
thinks is three characters long.  It then loops for ever reading the
null byte at the end of the string waiting to get to the third
character.

I think the answer might be never to expand aliases when the "x" would
be added to the command word.  That might be easier said than done.

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





More information about the Pkg-zsh-devel mailing list