junegunn/fzf

Streaming filter mode crashes

junegunn opened this issue · 0 comments

Checklist

  • I have read through the manual page (man fzf)
  • I have searched through the existing issues
  • For bug reports, I have checked if the bug is reproducible in the latest version of fzf

Output of fzf --version

0.49.0

OS

  • Linux
  • macOS
  • Windows
  • Etc.

Shell

  • bash
  • zsh
  • fish

Problem / Steps to reproduce

fzf --no-sort --filter=//
panic: runtime error: slice bounds out of range [15:8]

goroutine 19 [running]:
github.com/junegunn/fzf/src/algo.FuzzyMatchV2(0x0, 0x1, 0x1, 0x1400028d7c0, {0x140000b03b8?, 0x2, 0x2}, 0x0, 0x1400009ad50)
        /Users/jg/github/fzf/src/algo/algo.go:531 +0x1684
github.com/junegunn/fzf/src.(*Pattern).iter(0x1400009ad20?, 0x104d20498, {0x140000a7978?, 0x1, 0x104b49800?}, 0xe0?, 0xf0?, 0xe8?, {0x140000b03b8, 0x2, ...}, ...)
        /Users/jg/github/fzf/src/pattern.go:414 +0xd0
github.com/junegunn/fzf/src.(*Pattern).extendedMatch(0x140000fc000, 0x1?, 0x0, 0x104c5559c?)
        /Users/jg/github/fzf/src/pattern.go:370 +0x384
github.com/junegunn/fzf/src.(*Pattern).MatchItem(0x140000fc000, 0x14000296090?, 0xe8?, 0x104c74128?)
        /Users/jg/github/fzf/src/pattern.go:323 +0x30
github.com/junegunn/fzf/src.Run.func8({0x14000296090, 0x23, 0x30})
        /Users/jg/github/fzf/src/core.go:161 +0x94
github.com/junegunn/fzf/src.(*Reader).readFiles.func1({0x14000296000?, 0x140000b0630?}, {0x104d21dd8, 0x1400028d780}, {0x0?, 0x0?})
        /Users/jg/github/fzf/src/reader.go:161 +0xd8
github.com/charlievieth/fastwalk.(*walker).onDirEnt(0x1400008c4b0, {0x140000b0630?, 0x14000096d18?}, {0x14000290240?, 0x38?}, {0x104d21dd8, 0x1400028d780})
        /Users/jg/gosrc/pkg/mod/github.com/charlievieth/fastwalk@v1.0.2/fastwalk.go:342 +0xc0
github.com/charlievieth/fastwalk.readDir_Getdirentries({0x140000b0630, 0x9}, 0x140000a7e78)
        /Users/jg/gosrc/pkg/mod/github.com/charlievieth/fastwalk@v1.0.2/fastwalk_darwin.go:132 +0x4b0
github.com/charlievieth/fastwalk.readDir(...)
        /Users/jg/gosrc/pkg/mod/github.com/charlievieth/fastwalk@v1.0.2/fastwalk_darwin.go:19
github.com/charlievieth/fastwalk.(*walker).walk(0x1400008c4b0, {0x140000b0630, 0x9}, {0x104d21dd8, 0x140000bab80}, 0x1?)
        /Users/jg/gosrc/pkg/mod/github.com/charlievieth/fastwalk@v1.0.2/fastwalk.go:376 +0xb8
github.com/charlievieth/fastwalk.(*walker).doWork(0x1400008c4b0, 0x0?)
        /Users/jg/gosrc/pkg/mod/github.com/charlievieth/fastwalk@v1.0.2/fastwalk.go:257 +0xec
created by github.com/charlievieth/fastwalk.Walk
        /Users/jg/gosrc/pkg/mod/github.com/charlievieth/fastwalk@v1.0.2/fastwalk.go:202 +0x32c

This is because reader callback is run concurrently due to parallel execution of fastwalk when it shouldn't.