* Segfault when displaying completion lists @ 2016-02-08 22:58 Christian Heinrich 2016-02-08 23:39 ` Eric Cook 0 siblings, 1 reply; 4+ messages in thread From: Christian Heinrich @ 2016-02-08 22:58 UTC (permalink / raw) To: Zsh hackers list [-- Attachment #1: Type: text/plain, Size: 1004 bytes --] Hello, I'm running ZSH 5.2-3 on my Debian Testing system. This error existed previously, too, but I only found the time today to find a minimal setup for this. Here we go: % zsh --norcs % zmodload zsh/complist % autoload -U compinit && compinit -d ~/.zsh/cache/zcompdump % zstyle ':completion:*' list-prompt '%p' % bindkey -d % ls /usr/lib/<TAB> Now a huge list should be displayed with a pager. Press "Arrow Down" and it should segfault. This does not happen if the "zsh/complist" module is not loaded. Another interesting observation: After the <TAB>, press backspace instead of "arrow down" and remove the whole command (do not accept the line). Type "bindkey -d" (yes, a 2nd time) and accept. Type "ls /usr/lib/<TAB>" again and press backspace. It segfaults now, although backspacing worked the first time. Maybe someone can find the reason for this? I do have EDITOR="vim" set, but it appears as if it happens with EDITOR="emacs" as well. Thanks! Christian [-- Attachment #2: This is a digitally signed message part --] [-- Type: application/pgp-signature, Size: 801 bytes --] ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Segfault when displaying completion lists 2016-02-08 22:58 Segfault when displaying completion lists Christian Heinrich @ 2016-02-08 23:39 ` Eric Cook 2016-02-09 6:00 ` Bart Schaefer 0 siblings, 1 reply; 4+ messages in thread From: Eric Cook @ 2016-02-08 23:39 UTC (permalink / raw) To: zsh-workers On 02/08/2016 05:58 PM, Christian Heinrich wrote: > Hello, > > I'm running ZSH 5.2-3 on my Debian Testing system. This error existed > previously, too, but I only found the time today to find a minimal > setup for this. Here we go: > > % zsh --norcs > % zmodload zsh/complist > % autoload -U compinit && compinit -d ~/.zsh/cache/zcompdump > % zstyle ':completion:*' list-prompt '%p' > % bindkey -d > % ls /usr/lib/<TAB> > Now a huge list should be displayed with a pager. Press "Arrow Down" > and it should segfault. > > > This does not happen if the "zsh/complist" module is not loaded. > > Another interesting observation: > > After the <TAB>, press backspace instead of "arrow down" and remove the > whole command (do not accept the line). Type "bindkey -d" (yes, a 2nd > time) and accept. Type "ls /usr/lib/<TAB>" again and press backspace. > It segfaults now, although backspacing worked the first time. > > Maybe someone can find the reason for this? I do have EDITOR="vim" set, > but it appears as if it happens with EDITOR="emacs" as well. > > > Thanks! > > Christian > This is a guess: menu selection requires a keymap named menuselect to function. you can view it with ''bindkey -l''. This keymap is provided by the complist module that you loaded initially, then sequentially deleted with ''bindkey -d'' returning the keymaps back to a default state. The zsh/complist is loaded automatically on first use of menuselect, which explains why ''zmodload zsh/complist'' is required for the segfault. If my guess is true, zsh should handle the menuselect keymap not existing more elegantly. But i wouldn't expect menuselect to be of much use without keybinds. ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Segfault when displaying completion lists 2016-02-08 23:39 ` Eric Cook @ 2016-02-09 6:00 ` Bart Schaefer 2016-02-09 10:31 ` Christian Heinrich 0 siblings, 1 reply; 4+ messages in thread From: Bart Schaefer @ 2016-02-09 6:00 UTC (permalink / raw) To: zsh-workers On Feb 8, 6:39pm, Eric Cook wrote: } } This is a guess: Pretty good one. } If my guess is true, zsh should handle the menuselect keymap not } existing more elegantly. This is a bit brute-force, but perhaps the following? It has the added side-effect that if you create your own keymap named "menuselect" and/or "listscroll" before loading zsh/complist, your bindings take precedence. diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c index 06a07a4..937e1d1 100644 --- a/Src/Zle/complist.c +++ b/Src/Zle/complist.c @@ -989,6 +989,7 @@ asklistscroll(int ml) fflush(shout); zsetterm(); + menuselect_bindings(); /* sanity in case deleted by user */ selectlocalmap(lskeymap); if (!(cmd = getkeycmd()) || cmd == Th(z_sendbreak)) ret = 1; @@ -2433,6 +2434,7 @@ domenuselect(Hookdef dummy, Chdata dat) unqueue_signals(); mhasstat = (mstatus && *mstatus); fdat = dat; + menuselect_bindings(); /* sanity in case deleted by user */ selectlocalmap(mskeymap); noselect = 1; while ((menuacc && @@ -3486,6 +3488,37 @@ enables_(Module m, int **enables) } /**/ +static void +menuselect_bindings(void) +{ + if (!(mskeymap = openkeymap("menuselect"))) { + mskeymap = newkeymap(NULL, "menuselect"); + linkkeymap(mskeymap, "menuselect", 1); + bindkey(mskeymap, "\t", refthingy(t_completeword), NULL); + bindkey(mskeymap, "\n", refthingy(t_acceptline), NULL); + bindkey(mskeymap, "\r", refthingy(t_acceptline), NULL); + bindkey(mskeymap, "\33[A", refthingy(t_uplineorhistory), NULL); + bindkey(mskeymap, "\33[B", refthingy(t_downlineorhistory), NULL); + bindkey(mskeymap, "\33[C", refthingy(t_forwardchar), NULL); + bindkey(mskeymap, "\33[D", refthingy(t_backwardchar), NULL); + bindkey(mskeymap, "\33OA", refthingy(t_uplineorhistory), NULL); + bindkey(mskeymap, "\33OB", refthingy(t_downlineorhistory), NULL); + bindkey(mskeymap, "\33OC", refthingy(t_forwardchar), NULL); + bindkey(mskeymap, "\33OD", refthingy(t_backwardchar), NULL); + } + if (!(lskeymap = openkeymap("listscroll"))) { + lskeymap = newkeymap(NULL, "listscroll"); + linkkeymap(lskeymap, "listscroll", 1); + bindkey(lskeymap, "\t", refthingy(t_completeword), NULL); + bindkey(lskeymap, " ", refthingy(t_completeword), NULL); + bindkey(lskeymap, "\n", refthingy(t_acceptline), NULL); + bindkey(lskeymap, "\r", refthingy(t_acceptline), NULL); + bindkey(lskeymap, "\33[B", refthingy(t_downlineorhistory), NULL); + bindkey(lskeymap, "\33OB", refthingy(t_downlineorhistory), NULL); + } +} + +/**/ int boot_(Module m) { @@ -3503,27 +3536,7 @@ boot_(Module m) } addhookfunc("comp_list_matches", (Hookfn) complistmatches); addhookfunc("menu_start", (Hookfn) domenuselect); - mskeymap = newkeymap(NULL, "menuselect"); - linkkeymap(mskeymap, "menuselect", 1); - bindkey(mskeymap, "\t", refthingy(t_completeword), NULL); - bindkey(mskeymap, "\n", refthingy(t_acceptline), NULL); - bindkey(mskeymap, "\r", refthingy(t_acceptline), NULL); - bindkey(mskeymap, "\33[A", refthingy(t_uplineorhistory), NULL); - bindkey(mskeymap, "\33[B", refthingy(t_downlineorhistory), NULL); - bindkey(mskeymap, "\33[C", refthingy(t_forwardchar), NULL); - bindkey(mskeymap, "\33[D", refthingy(t_backwardchar), NULL); - bindkey(mskeymap, "\33OA", refthingy(t_uplineorhistory), NULL); - bindkey(mskeymap, "\33OB", refthingy(t_downlineorhistory), NULL); - bindkey(mskeymap, "\33OC", refthingy(t_forwardchar), NULL); - bindkey(mskeymap, "\33OD", refthingy(t_backwardchar), NULL); - lskeymap = newkeymap(NULL, "listscroll"); - linkkeymap(lskeymap, "listscroll", 1); - bindkey(lskeymap, "\t", refthingy(t_completeword), NULL); - bindkey(lskeymap, " ", refthingy(t_completeword), NULL); - bindkey(lskeymap, "\n", refthingy(t_acceptline), NULL); - bindkey(lskeymap, "\r", refthingy(t_acceptline), NULL); - bindkey(lskeymap, "\33[B", refthingy(t_downlineorhistory), NULL); - bindkey(lskeymap, "\33OB", refthingy(t_downlineorhistory), NULL); + menuselect_bindings(); return 0; } ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Segfault when displaying completion lists 2016-02-09 6:00 ` Bart Schaefer @ 2016-02-09 10:31 ` Christian Heinrich 0 siblings, 0 replies; 4+ messages in thread From: Christian Heinrich @ 2016-02-09 10:31 UTC (permalink / raw) To: zsh-workers [-- Attachment #1: Type: text/plain, Size: 4833 bytes --] Thanks guys, that was exactly the issue. I recompiled the code and it works just as it should! Christian On Mon, 2016-02-08 at 22:00 -0800, Bart Schaefer wrote: > On Feb 8, 6:39pm, Eric Cook wrote: > } > } This is a guess: > > Pretty good one. > > } If my guess is true, zsh should handle the menuselect keymap not > } existing more elegantly. > > This is a bit brute-force, but perhaps the following? It has the > added > side-effect that if you create your own keymap named "menuselect" > and/or > "listscroll" before loading zsh/complist, your bindings take > precedence. > > diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c > index 06a07a4..937e1d1 100644 > --- a/Src/Zle/complist.c > +++ b/Src/Zle/complist.c > @@ -989,6 +989,7 @@ asklistscroll(int ml) > > fflush(shout); > zsetterm(); > + menuselect_bindings(); /* sanity in case deleted by user > */ > selectlocalmap(lskeymap); > if (!(cmd = getkeycmd()) || cmd == Th(z_sendbreak)) > ret = 1; > @@ -2433,6 +2434,7 @@ domenuselect(Hookdef dummy, Chdata dat) > unqueue_signals(); > mhasstat = (mstatus && *mstatus); > fdat = dat; > + menuselect_bindings(); /* sanity in case deleted by user > */ > selectlocalmap(mskeymap); > noselect = 1; > while ((menuacc && > @@ -3486,6 +3488,37 @@ enables_(Module m, int **enables) > } > > /**/ > +static void > +menuselect_bindings(void) > +{ > + if (!(mskeymap = openkeymap("menuselect"))) { > + mskeymap = newkeymap(NULL, "menuselect"); > + linkkeymap(mskeymap, "menuselect", 1); > + bindkey(mskeymap, "\t", refthingy(t_completeword), NULL); > + bindkey(mskeymap, "\n", refthingy(t_acceptline), NULL); > + bindkey(mskeymap, "\r", refthingy(t_acceptline), NULL); > + bindkey(mskeymap, "\33[A", refthingy(t_uplineorhistory), > NULL); > + bindkey(mskeymap, "\33[B", refthingy(t_downlineorhistory), > NULL); > + bindkey(mskeymap, "\33[C", refthingy(t_forwardchar), NULL); > + bindkey(mskeymap, "\33[D", refthingy(t_backwardchar), > NULL); > + bindkey(mskeymap, "\33OA", refthingy(t_uplineorhistory), > NULL); > + bindkey(mskeymap, "\33OB", refthingy(t_downlineorhistory), > NULL); > + bindkey(mskeymap, "\33OC", refthingy(t_forwardchar), NULL); > + bindkey(mskeymap, "\33OD", refthingy(t_backwardchar), > NULL); > + } > + if (!(lskeymap = openkeymap("listscroll"))) { > + lskeymap = newkeymap(NULL, "listscroll"); > + linkkeymap(lskeymap, "listscroll", 1); > + bindkey(lskeymap, "\t", refthingy(t_completeword), NULL); > + bindkey(lskeymap, " ", refthingy(t_completeword), NULL); > + bindkey(lskeymap, "\n", refthingy(t_acceptline), NULL); > + bindkey(lskeymap, "\r", refthingy(t_acceptline), NULL); > + bindkey(lskeymap, "\33[B", refthingy(t_downlineorhistory), > NULL); > + bindkey(lskeymap, "\33OB", refthingy(t_downlineorhistory), > NULL); > + } > +} > + > +/**/ > int > boot_(Module m) > { > @@ -3503,27 +3536,7 @@ boot_(Module m) > } > addhookfunc("comp_list_matches", (Hookfn) complistmatches); > addhookfunc("menu_start", (Hookfn) domenuselect); > - mskeymap = newkeymap(NULL, "menuselect"); > - linkkeymap(mskeymap, "menuselect", 1); > - bindkey(mskeymap, "\t", refthingy(t_completeword), NULL); > - bindkey(mskeymap, "\n", refthingy(t_acceptline), NULL); > - bindkey(mskeymap, "\r", refthingy(t_acceptline), NULL); > - bindkey(mskeymap, "\33[A", refthingy(t_uplineorhistory), NULL); > - bindkey(mskeymap, "\33[B", refthingy(t_downlineorhistory), > NULL); > - bindkey(mskeymap, "\33[C", refthingy(t_forwardchar), NULL); > - bindkey(mskeymap, "\33[D", refthingy(t_backwardchar), NULL); > - bindkey(mskeymap, "\33OA", refthingy(t_uplineorhistory), NULL); > - bindkey(mskeymap, "\33OB", refthingy(t_downlineorhistory), > NULL); > - bindkey(mskeymap, "\33OC", refthingy(t_forwardchar), NULL); > - bindkey(mskeymap, "\33OD", refthingy(t_backwardchar), NULL); > - lskeymap = newkeymap(NULL, "listscroll"); > - linkkeymap(lskeymap, "listscroll", 1); > - bindkey(lskeymap, "\t", refthingy(t_completeword), NULL); > - bindkey(lskeymap, " ", refthingy(t_completeword), NULL); > - bindkey(lskeymap, "\n", refthingy(t_acceptline), NULL); > - bindkey(lskeymap, "\r", refthingy(t_acceptline), NULL); > - bindkey(lskeymap, "\33[B", refthingy(t_downlineorhistory), > NULL); > - bindkey(lskeymap, "\33OB", refthingy(t_downlineorhistory), > NULL); > + menuselect_bindings(); > return 0; > } > [-- Attachment #2: This is a digitally signed message part --] [-- Type: application/pgp-signature, Size: 801 bytes --] ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-02-09 10:31 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2016-02-08 22:58 Segfault when displaying completion lists Christian Heinrich 2016-02-08 23:39 ` Eric Cook 2016-02-09 6:00 ` Bart Schaefer 2016-02-09 10:31 ` Christian Heinrich
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).