Subject: Re: segfault in completion for configure
From: Vincent Lefevre <[email-masked]>
To: [email-masked]
Date: Sat, 12 Mar 2016 04:11:16 +0100
List-Id: Zsh Workers List <zsh-workers.zsh.org>

On 2016-03-11 15:00:56 -0800, Bart Schaefer wrote:
> Shot in the [mostly] dark:  I see TRAPCHLD embedded in one of the strings
> in your backtrace.  Completion after "configure --" forks at least one
> child process (says valgrind) so if you have a TRAPCHLD function it's
> possible that it's corrupting something.  We do attempt signal handling
> during pattern matching in order that deep recursive globs can be stopped
> with SIGINT; it could be that needs a bit more regulation.

FYI, here's my TRAPCHLD:

TRAPCHLD()
{
  if [[ -o interactive && -n $TTY ]] then
    updprompt
    typeset -g _trapchld_called=1
  fi
}

with:

updprompt()
{
  psvar[2]=""

  unset _trapchld_called
  local njobs jobstr
  njobs=$#jobstates
  [[ $njobs -gt 1 ]] && jobstr="s"
  [[ $njobs -ge 1 ]] && jobstr=" $njobs job$jobstr |"

  [[ -n $TTY && $TERM == (xterm*|dtterm|mlterm|rxvt*|screen*) ]] &&
    {
      [[ $TERM == screen* ]] || print -nP "\e]1;%m${ptsn:+[$ptsn]}:%.\x07"
      print -nP "\e]2;${jobstr}${WINTITLE:+ $WINTITLE |} %n@%m - %~ | %y\x07"
    } > /dev/tty

  [[ -n $_trapchld_called ]] && updprompt
}

I can't reproduce the bug if I remove:

  [[ -n $TTY && $TERM == (xterm*|dtterm|mlterm|rxvt*|screen*) ]] &&
    {
      [[ $TERM == screen* ]] || print -nP "\e]1;%m${ptsn:+[$ptsn]}:%.\x07"
      print -nP "\e]2;${jobstr}${WINTITLE:+ $WINTITLE |} %n@%m - %~ | %y\x07"
    } > /dev/tty

-- 
Vincent Lefèvre <[email-masked]> - 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)