antonmedv / walk

Terminal file manager
MIT License
3.17k stars 89 forks source link

Nonexist start path listing and empty directory previewing both lead to panic, version v1.9.0 #142

Closed rustyhu closed 2 weeks ago

rustyhu commented 3 weeks ago

Nonexist start path listing:

~> walk kkk
Caught panic:

runtime error: makeslice: len out of range

Restoring terminal...

goroutine 1 [running]:
runtime/debug.Stack()
        /usr/lib/go-1.21/src/runtime/debug/stack.go:24 +0x5e
runtime/debug.PrintStack()
        /usr/lib/go-1.21/src/runtime/debug/stack.go:16 +0x13
github.com/charmbracelet/bubbletea.(*Program).Run.func1()
        /somepath/go/pkg/mod/github.com/charmbracelet/bubbletea@v0.26.5/tea.go:479 +0x91
panic({0x558e40?, 0x5c2cf0?})
        /usr/lib/go-1.21/src/runtime/panic.go:920 +0x270
main.(*model).View(0xc00015c000)
        /somepath/walk/main.go:486 +0x2cb
github.com/charmbracelet/bubbletea.(*Program).Run(0xc00015e000)
        /somepath/go/pkg/mod/github.com/charmbracelet/bubbletea@v0.26.5/tea.go:534 +0x964
main.main()
        /somepath/walk/main.go:132 +0x525

Empty directory previewing:

Caught panic:

runtime error: makeslice: len out of range

Restoring terminal...

goroutine 1 [running]:
runtime/debug.Stack()
        /usr/lib/go-1.21/src/runtime/debug/stack.go:24 +0x5e
runtime/debug.PrintStack()
        /usr/lib/go-1.21/src/runtime/debug/stack.go:16 +0x13
github.com/charmbracelet/bubbletea.(*Program).Run.func1()
        /somepath/go/pkg/mod/github.com/charmbracelet/bubbletea@v0.26.5/tea.go:479 +0x91
panic({0x558e40?, 0x5c2cf0?})
        /usr/lib/go-1.21/src/runtime/panic.go:920 +0x270
main.(*model).preview(0xc000180000)
        /somepath/walk/main.go:777 +0x1c5
main.(*model).View(0xc000180000)
        /somepath/walk/main.go:467 +0x15f
github.com/charmbracelet/bubbletea.(*Program).eventLoop(0xc000184000, {0x5c3c98?, 0xc000180000?}, 0x5?)
        /somepath/go/pkg/mod/github.com/charmbracelet/bubbletea@v0.26.5/tea.go:414 +0x8ad
github.com/charmbracelet/bubbletea.(*Program).Run(0xc000184000)
        /somepath/go/pkg/mod/github.com/charmbracelet/bubbletea@v0.26.5/tea.go:550 +0xaf2
main.main()
        /somepath/walk/main.go:132 +0x525

Both lead to invalid rows number returned from algorithm of wrap(), which are used in make([]string, rows), then lead to runtime error: makeslice: len out of range.

bokunodev commented 2 weeks ago

samething happen while trying to enter directory with no permission.

Caught panic:

runtime error: makeslice: len out of range

Restoring terminal...

goroutine 1 [running]:
runtime/debug.Stack()
        /home/guest/.local/src/go/src/runtime/debug/stack.go:24 +0x5e
runtime/debug.PrintStack()
        /home/guest/.local/src/go/src/runtime/debug/stack.go:16 +0x13
github.com/charmbracelet/bubbletea.(*Program).Run.func1()
        /home/guest/.go/pkg/mod/github.com/charmbracelet/bubbletea@v0.26.5/tea.go:479 +0x91
panic({0x5625c0?, 0x5cf7b0?})
        /home/guest/.local/src/go/src/runtime/panic.go:770 +0x132
main.(*model).View(0xc00011d0e0)
        /home/guest/.go/pkg/mod/github.com/antonmedv/walk@v1.9.0/main.go:486 +0x2b1
github.com/charmbracelet/bubbletea.(*Program).eventLoop(0xc000150200, {0x5d0998?, 0xc00011d0e0?}, 0xc00008e180)
        /home/guest/.go/pkg/mod/github.com/charmbracelet/bubbletea@v0.26.5/tea.go:414 +0x707
github.com/charmbracelet/bubbletea.(*Program).Run(0xc000150200)
        /home/guest/.go/pkg/mod/github.com/charmbracelet/bubbletea@v0.26.5/tea.go:550 +0xa0e
main.main()
        /home/guest/.go/pkg/mod/github.com/antonmedv/walk@v1.9.0/main.go:132 +0x511
oderwat commented 2 weeks ago

Got this one too when trying 'walk' the first time today.

antonmedv commented 2 weeks ago

Fixed.