zsh-workers
 help / color / mirror / code / Atom feed
* Crash after interrupting tab-completion with Ctrl-\
@ 2014-10-27  0:38 Vincent Lefevre
  2014-10-27  1:31 ` Bart Schaefer
  0 siblings, 1 reply; 8+ messages in thread
From: Vincent Lefevre @ 2014-10-27  0:38 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 624 bytes --]

With zsh 5.0.7 (Debian package), I did a tab-completion, which
generated endless output (I don't know why, and I don't remember the
command). I typed Ctrl-\ to interrupt it (Ctrl-C had no effect), but
zsh immediately crashed (the terminal disappeared as a consequence).
Unfortunately it didn't leave a core file.

I've attached the file containing my completion settings, which is
sourced by my .zshrc file.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

[-- Attachment #2: .zcomp --]
[-- Type: text/plain, Size: 4787 bytes --]

############################
# Vincent Lefèvre's .zcomp #
############################

# Completion for zsh

zcomp_id='$Id: zcomp 73120 2014-09-16 11:39:50Z vinc17/ypig $'

# The following lines were added by compinstall

zstyle ':completion:*' auto-description 'specify: %d'
zstyle ':completion:*' completer _complete
zstyle ':completion:*' format 'Completing %d'
zstyle ':completion:*' ignore-parents parent pwd
zstyle ':completion:*' insert-tab false
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*'
zstyle ':completion:*' max-errors 1
zstyle ':completion:*' menu select=long
zstyle ':completion:*' preserve-prefix '//[^/]##/'
zstyle :compinstall filename '.zcomp'

autoload -U compinit
compinit
# End of lines added by compinstall

# Suggestion from
#   From: Peter Stephenson <pws@csr.com>
#   Date: Thu, 11 Mar 2004 12:28:17 +0000
#   Subject: Re: cd completion and CDABLE_VARS
#   To: zsh-users@sunsite.dk
#   Message-ID: <14646.1079008097@csr.com>
#   http://www.zsh.org/mla/users/2004/msg00150.html
# to disable named directories in the first completion choices.
zstyle ':completion:*:complete:(cd|pushd):*' tag-order \
  'local-directories path-directories directory-stack' '*'

# When starting to type a command, avoid the completion on directories
# and executables in the cwd (except if there are no matches). However
# if auto_cd is used with a cdpath, the behavior is a bit inconsistent.
# This can be fixed by a modified _autocd function.
zstyle ':completion:*:complete:-command-:*' tag-order 'commands builtins functions aliases suffix-aliases reserved-words jobs parameters' 'executables' '*'

# Suggestion from
#   From: Bart Schaefer <schaefer@brasslantern.com>
#   Date: Wed, 21 Jul 2004 17:32:36 -0700 (PDT)
#   Subject: Re: TAB at the command line beginning
#   To: Zsh Mailinglist <zsh-users@sunsite.dk>
#   Message-ID: <Pine.LNX.4.61.0407211649070.20062@toltec.zanshin.com>
#   http://www.zsh.org/mla/users/2004/msg00743.html
history-search-or-expand-or-complete()
{
  if [[ -z "$BUFFER" && -z "$PREBUFFER" ]] then
    zle history-incremental-search-backward "$@"
  else
    zle expand-or-complete "$@"
  fi
}
zle -N history-search-or-expand-or-complete
bindkey '\t' history-search-or-expand-or-complete

# Suggestion from
#   From: Bart Schaefer <schaefer@brasslantern.com>
#   Date: Thu, 19 Aug 2004 10:16:10 -0700 (PDT)
#   Subject: Re: Tip of the day: previous command output
#   To: Zsh-users List <zsh-users@sunsite.dk>
#   Message-ID: <Pine.LNX.4.61.0408190956440.9464@toltec.zanshin.com>
#   http://www.zsh.org/mla/users/2004/msg00896.html
# and following messages...
keep()
{
  kept=()
  kept=( $~* )
  if [[ ! -t 0 ]] then
    while read line; do
      kept+=( $line )
    done
  fi
  print -Rc - $kept
}
alias keep='noglob keep '

_insert_kept()
{
  (( $#kept )) || return 1
  local action
  zstyle -s :completion:$curcontext insert-kept action
  [[ -n $action ]] && compstate[insert]=$action
  compadd -a kept
}
zle -C insert-kept-result complete-word _generic
zstyle ':completion:insert-kept-result:*' completer _insert_kept
zstyle ':completion:*' insert-kept all
bindkey '\e\t' insert-kept-result

# Suggestion from the manual and
#   From: Bart Schaefer <schaefer@brasslantern.com>
#   Date: Sat, 19 Aug 2006 20:16:27 -0700
#   Subject: Re: How to insert completions on command line
#   To: zsh-users@sunsite.dk
#   Message-id: <060819201627.ZM28979@torch.brasslantern.com>
#   http://www.zsh.org/mla/users/2006/msg00820.html
zle -C all-matches complete-word _generic
bindkey '^X\t' all-matches
zstyle ':completion:all-matches:*' insert yes
zstyle ':completion:all-matches::::' completer _all_matches _complete

# See subthread
#   From: Peter Stephenson <pws@csr.com>
#   Date: Mon, 18 Jun 2007 11:09:48 +0100
#   Subject: Re: conditionally match part of file name to most recently
#           modified file
#   To: Zsh Users <zsh-users@sunsite.dk>
#   Message-ID: <20070618110948.3d8d739f@news01.csr.com>
#   http://www.zsh.org/mla/users/2007/msg00483.html
zle -C most-recent-file menu-complete _generic
bindkey '^X.' most-recent-file
zstyle ':completion:most-recent-file:*' match-original both
zstyle ':completion:most-recent-file:*' file-sort modification
zstyle ':completion:most-recent-file:*' file-patterns '*(-^/):all-files'
zstyle ':completion:most-recent-file:*' hidden all
zstyle ':completion:most-recent-file::::' completer _menu _files _match

# The pager-wrapper function, defined in .zalias, is regarded as a precommand.
compdef _precommand pager-wrapper

# Completion for user commands
compdef eclient=emacs
compdef svnwrapper=svn

# Note: interesting information can be obtained with _complete_help (^Xh).

# local variables:
# mode: sh
# end:

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Crash after interrupting tab-completion with Ctrl-\
  2014-10-27  0:38 Crash after interrupting tab-completion with Ctrl-\ Vincent Lefevre
@ 2014-10-27  1:31 ` Bart Schaefer
  2014-10-27  2:18   ` Bart Schaefer
  2014-10-27 14:32   ` Vincent Lefevre
  0 siblings, 2 replies; 8+ messages in thread
From: Bart Schaefer @ 2014-10-27  1:31 UTC (permalink / raw)
  To: zsh-workers

On Oct 27,  1:38am, Vincent Lefevre wrote:
} 
} With zsh 5.0.7 (Debian package), I did a tab-completion, which
} generated endless output (I don't know why, and I don't remember the
} command). I typed Ctrl-\ to interrupt it (Ctrl-C had no effect), but
} zsh immediately crashed (the terminal disappeared as a consequence).

That's curious, because just with some simple tests (a completer that
contains a sleep) I'm not able to get ctrl-\ to do anything, but ctrl-C
interrupts the completion.

In fact even with a trap on QUIT in place, the stty quit character does
not seem to do anything until an external process is in the foreground.

I don't see anything in your .zcomp that looks likely to affect this,
so unlss you manage to remember what command you were completing for,
we may not get very far.

Can you check whether $^fpath/_call_program(N[1]) seems to contain the
patch from workers/33403 ?


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Crash after interrupting tab-completion with Ctrl-\
  2014-10-27  1:31 ` Bart Schaefer
@ 2014-10-27  2:18   ` Bart Schaefer
  2014-10-27  8:16     ` Mikael Magnusson
  2014-10-27 14:40     ` Vincent Lefevre
  2014-10-27 14:32   ` Vincent Lefevre
  1 sibling, 2 replies; 8+ messages in thread
From: Bart Schaefer @ 2014-10-27  2:18 UTC (permalink / raw)
  To: zsh-workers

On Oct 26,  6:31pm, Bart Schaefer wrote:
}
} In fact even with a trap on QUIT in place, the stty quit character does
} not seem to do anything until an external process is in the foreground.

zsetterm() disables the tty quit character, along with a bunch of others.
So if you were able to use it, you'd somehow gotten out of ZLE.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Crash after interrupting tab-completion with Ctrl-\
  2014-10-27  2:18   ` Bart Schaefer
@ 2014-10-27  8:16     ` Mikael Magnusson
  2014-10-27 14:40     ` Vincent Lefevre
  1 sibling, 0 replies; 8+ messages in thread
From: Mikael Magnusson @ 2014-10-27  8:16 UTC (permalink / raw)
  To: zsh workers

On Mon, Oct 27, 2014 at 3:18 AM, Bart Schaefer
<schaefer@brasslantern.com> wrote:
> On Oct 26,  6:31pm, Bart Schaefer wrote:
> }
> } In fact even with a trap on QUIT in place, the stty quit character does
> } not seem to do anything until an external process is in the foreground.
>
> zsetterm() disables the tty quit character, along with a bunch of others.
> So if you were able to use it, you'd somehow gotten out of ZLE.

Is it possible that you (Vincent) held down the QUIT key, and there
was a race where the signal got sent to zsh before zle had a chance to
disable the quit character? This sometimes happens to me when trying
to break out of for loops that do a bit more than I intended and I end
up killing zsh as well.

-- 
Mikael Magnusson


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Crash after interrupting tab-completion with Ctrl-\
  2014-10-27  1:31 ` Bart Schaefer
  2014-10-27  2:18   ` Bart Schaefer
@ 2014-10-27 14:32   ` Vincent Lefevre
  1 sibling, 0 replies; 8+ messages in thread
From: Vincent Lefevre @ 2014-10-27 14:32 UTC (permalink / raw)
  To: zsh-workers

On 2014-10-26 18:31:05 -0700, Bart Schaefer wrote:
> Can you check whether $^fpath/_call_program(N[1]) seems to contain the
> patch from workers/33403 ?

Yes, it does:

[...]
if (( ${debug_fd:--1} > 2 )) || [[ ! -t 2 ]]
then exec {err_fd}>&2   # debug_fd is saved stderr, 2 is trace or redirect
else exec {err_fd}>/dev/null
fi
[...]

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Crash after interrupting tab-completion with Ctrl-\
  2014-10-27  2:18   ` Bart Schaefer
  2014-10-27  8:16     ` Mikael Magnusson
@ 2014-10-27 14:40     ` Vincent Lefevre
  2014-10-27 14:51       ` Vincent Lefevre
  2014-10-28 16:24       ` Bart Schaefer
  1 sibling, 2 replies; 8+ messages in thread
From: Vincent Lefevre @ 2014-10-27 14:40 UTC (permalink / raw)
  To: zsh-workers

On 2014-10-26 19:18:18 -0700, Bart Schaefer wrote:
> On Oct 26,  6:31pm, Bart Schaefer wrote:
> }
> } In fact even with a trap on QUIT in place, the stty quit character does
> } not seem to do anything until an external process is in the foreground.
> 
> zsetterm() disables the tty quit character, along with a bunch of others.
> So if you were able to use it, you'd somehow gotten out of ZLE.

Apparently not. I can reproduce the problem.

$ ls Mail/oldarc/cur/1[TAB]
zsh: do you wish to see all 140500 possibilities (70251 lines)? 

Then I type 'y', followed by Ctrl-\.

[...]
1061504484.3678_503.ay:2,S           1215744604.19156_1028.prunille:2,S 
1061504484.3678_505.ay:2,S           1215744604.19156_1030.prunille:2,S 
1061504484.3678_507.ay:2,S           1215744604.19156_1032.prunille:2,S 
1061504484.3678_509.ay:2,S           1215744604.19156_1034.prunille:2,S 
1061504484.3678_511.ay:2,S           1215744604.19156_1036.prunille:2,S 
106150448^\zsh: quit (core dumped)  zsh

xvii:~> gdb =zsh core
GNU gdb (Debian 7.7.1+dfsg-3) 7.7.1
[...]
Core was generated by `zsh'.
Program terminated with signal SIGQUIT, Quit.
#0  0x00007f1610886453 in skipnolist (p=0x3153510, showall=showall@entry=0)
    at ../../../Src/Zle/compresult.c:1488
1488    ../../../Src/Zle/compresult.c: No such file or directory.
(gdb) bt
#0  0x00007f1610886453 in skipnolist (p=0x3153510, showall=showall@entry=0)
    at ../../../Src/Zle/compresult.c:1488
#1  0x00007f1610459fb1 in compprintlist (showall=0)
    at ../../../Src/Zle/complist.c:1623
#2  complistmatches (dummy=<optimized out>, dat=<optimized out>)
    at ../../../Src/Zle/complist.c:2078
#3  0x00007f161088880e in list_matches (dummy=<optimized out>, 
    dummy2=<optimized out>) at ../../../Src/Zle/compresult.c:2334
#4  0x00007f1610ab743a in zrefresh () at ../../../Src/Zle/zle_refresh.c:1731
#5  0x00007f1610aac946 in zlecore () at ../../../Src/Zle/zle_main.c:1147
#6  0x00007f1610aad452 in zleread (lp=<optimized out>, rp=<optimized out>, 
    flags=<optimized out>, context=<optimized out>, 
    init=0x7f1610ac8621 "zle-line-init", 
    finish=0x7f1610ac8611 "zle-line-finish")
    at ../../../Src/Zle/zle_main.c:1289
#7  0x000000000043e582 in zleentry (cmd=cmd@entry=1) at ../../Src/init.c:1495
#8  0x000000000043f4c1 in inputline () at ../../Src/input.c:285
#9  ingetc () at ../../Src/input.c:221
#10 0x000000000043f685 in ingetc () at ../../Src/input.c:224
#11 0x00000000004382eb in ihgetc () at ../../Src/hist.c:282
#12 0x0000000000448bde in gettok () at ../../Src/lex.c:720
#13 zshlex () at ../../Src/lex.c:401
#14 0x00000000004496ee in zshlex () at ../../Src/lex.c:398
#15 0x0000000000464ec7 in parse_event () at ../../Src/parse.c:454
#16 0x000000000043b7c9 in loop (toplevel=toplevel@entry=1, 
    justonce=justonce@entry=0) at ../../Src/init.c:132
#17 0x000000000043ebee in zsh_main (argc=<optimized out>, argv=<optimized out>)
    at ../../Src/init.c:1650
#18 0x00007f1619397b45 in __libc_start_main (main=0x40f930 <main>, argc=1, 
    argv=0x7fffe8f7b4f8, init=<optimized out>, fini=<optimized out>, 
    rtld_fini=<optimized out>, stack_end=0x7fffe8f7b4e8) at libc-start.c:287
#19 0x000000000040f95e in _start ()

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Crash after interrupting tab-completion with Ctrl-\
  2014-10-27 14:40     ` Vincent Lefevre
@ 2014-10-27 14:51       ` Vincent Lefevre
  2014-10-28 16:24       ` Bart Schaefer
  1 sibling, 0 replies; 8+ messages in thread
From: Vincent Lefevre @ 2014-10-27 14:51 UTC (permalink / raw)
  To: zsh-workers

On 2014-10-27 15:40:55 +0100, Vincent Lefevre wrote:
> Apparently not. I can reproduce the problem.

And this is reproducible with "zsh -f" and:

  autoload -U compinit
  compinit

(no problems without compinit).

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Crash after interrupting tab-completion with Ctrl-\
  2014-10-27 14:40     ` Vincent Lefevre
  2014-10-27 14:51       ` Vincent Lefevre
@ 2014-10-28 16:24       ` Bart Schaefer
  1 sibling, 0 replies; 8+ messages in thread
From: Bart Schaefer @ 2014-10-28 16:24 UTC (permalink / raw)
  To: zsh-workers

On Oct 27,  3:40pm, Vincent Lefevre wrote:
} Subject: Re: Crash after interrupting tab-completion with Ctrl-\
}
} $ ls Mail/oldarc/cur/1[TAB]
} zsh: do you wish to see all 140500 possibilities (70251 lines)? 
} 
} Then I type 'y', followed by Ctrl-\.

Ok, so this isn't really a crash -- it's the default response to a QUIT
signal.  I just did a quick check and the QUIT handler is not reset, so
this is as expected, except that the stty quit character is supposed to
be disabled at this point (I think).  So the questions are:

- How did the quit character get re-enabled? - and

- Why doesn't INT work here?

I'm not too worried about the first one, since it seems to have been
fortuitous.  As for the latter, the following patch is not perfect --
it causes some screen-repaint problems if you manage to send the INT
before the first test of !errflag, and I may have gone overboard with
places the flag is tested -- but please see if it allows you to stop
that 70k-line listing.

Also fixed thinko in the _main_complete trap, although we've already
left _main_complete by the time printcomplist() is running.

diff --git a/Completion/Base/Core/_main_complete b/Completion/Base/Core/_main_complete
index e881ea6..fcd6366 100644
--- a/Completion/Base/Core/_main_complete
+++ b/Completion/Base/Core/_main_complete
@@ -128,7 +128,7 @@ _completer_num=1
 
 # We assume localtraps to be in effect here ...
 integer SECONDS=0
-trap 'zle -M "Killed by signal in ${funcstack[0]} after ${SECONDS}s";
+trap 'zle -M "Killed by signal in ${funcstack[1]} after ${SECONDS}s";
       zle -R; return 130' INT QUIT
 
 # Call the pre-functions.
diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index 5e5ba9f..2e1a527 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -1375,7 +1375,7 @@ compprintlist(int showall)
 	tcout(TCCLEAREOD);
 
     g = ((lasttype && lastg) ? lastg : amatches);
-    while (g) {
+    while (g && !errflag) {
 	char **pp = g->ylist;
 
 #ifdef ZSH_HEAP_DEBUG
@@ -1389,7 +1389,7 @@ compprintlist(int showall)
 		ml = lastml;
 		lastused = 1;
 	    }
-	    while (*e) {
+	    while (*e && !errflag) {
 		if (((*e)->count || (*e)->always) &&
 		    (!listdat.onlyexpl ||
 		     (listdat.onlyexpl & ((*e)->always > 0 ? 2 : 1)))) {
@@ -1469,11 +1469,11 @@ compprintlist(int showall)
 
 		nl = nc = g->lins;
 
-		while (n && nl--) {
+		while (n && nl-- && !errflag) {
 		    i = g->cols;
 		    mc = 0;
 		    pq = pp;
-		    while (n && i--) {
+		    while (n && i-- && !errflag) {
 			if (pq - g->ylist >= g->lcount)
 			    break;
 			if (compzputs(*pq, mscroll))
@@ -1582,7 +1582,7 @@ compprintlist(int showall)
 	    } else
 		p = skipnolist(g->matches, showall);
 
-	    while (n && nl--) {
+	    while (n && nl-- && !errflag) {
 		if (!lasttype && ml >= mlbeg) {
 		    lasttype = 3;
 		    lastg = g;
@@ -1596,7 +1596,7 @@ compprintlist(int showall)
 		i = g->cols;
 		mc = 0;
 		q = p;
-		while (n && i--) {
+		while (n && i-- && !errflag) {
 		    wid = (g->widths ? g->widths[mc] : g->width);
 		    if (!(m = *q)) {
 			if (clprintm(g, NULL, mc, ml, (!i), wid))


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-10-28 16:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-27  0:38 Crash after interrupting tab-completion with Ctrl-\ Vincent Lefevre
2014-10-27  1:31 ` Bart Schaefer
2014-10-27  2:18   ` Bart Schaefer
2014-10-27  8:16     ` Mikael Magnusson
2014-10-27 14:40     ` Vincent Lefevre
2014-10-27 14:51       ` Vincent Lefevre
2014-10-28 16:24       ` Bart Schaefer
2014-10-27 14:32   ` Vincent Lefevre

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).