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

Segfault completing find -exec (since 54889?)



Hi,

I'm running current master (5.9.999.3-test) and hit a segfault in completion. Easy to reproduce:

  zsh -f
  autoload -Uz compinit; compinit
  find . -exec '{}' <TAB>

The shell dies with SIGSEGV. Backtrace from a -g -O0 build:

  #0 pattryrefs (prog=0x0, string="", ...) at pattern.c:2306
  #1 pattry (prog=0x0, string="") at pattern.c:2230
  #2 ca_parse_line (...) at computil.c:2148
  #3 bin_comparguments (...) at computil.c:2676

So pattry() gets called with endpat == NULL.

I think this comes from 54889 (7a43a20cd), which added a "goto cont" after

  } else if ((state.def = state.def->next)) {

That jump skips the patcompile() of state.def->end at the bottom of the loop. _find's -exec spec has one normal argument followed by a rest argument with an end pattern (*(\;|+)), so after the program word, state.def points at a definition with ->end set while endpat was never compiled. The next word then crashes at line 2148.

Reverting just that goto makes the crash go away here. I haven't looked into what the right fix is without undoing what 54889 was meant to do.

I'm not subscribed, so please Cc me on replies.

Cheers,
Han


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