resh icon indicating copy to clipboard operation
resh copied to clipboard

panic: runtime error: slice bounds out of range

Open ilyavaiser opened this issue 3 years ago • 7 comments

Last login: Tue Sep 14 12:46:38 on ttys002 @2020 Portainer % panic: runtime error: slice bounds out of range

goroutine 1 [running]: github.com/curusarn/resh/pkg/searchapp.leftCutPadString(0xc0003d7ce0, 0x2a, 0xfffffffffffffff3, 0xc000704b30, 0x10) /home/runner/work/resh/resh/pkg/searchapp/item.go:249 +0x13d github.com/curusarn/resh/pkg/searchapp.ItemColumns.ProduceLine(0xc000704b30, 0x10, 0xc000704a00, 0x7, 0xc0006d2dc0, 0x36, 0xc0003d7c80, 0x2d, 0xc0003d7ce0, 0x2a, ...) /home/runner/work/resh/resh/pkg/searchapp/item.go:217 +0x1b2 main.manager.normalMode(0x7ffeefbff7c5, 0x24, 0x7ffeefbff7f1, 0x10, 0x7ffeefbff808, 0x35, 0x7ffeefbff850, 0x32, 0xa43, 0x78, ...) /home/runner/work/resh/resh/cmd/cli/main.go:517 +0x890 main.manager.Layout(0x7ffeefbff7c5, 0x24, 0x7ffeefbff7f1, 0x10, 0x7ffeefbff808, 0x35, 0x7ffeefbff850, 0x32, 0xa43, 0x78, ...) /home/runner/work/resh/resh/cmd/cli/main.go:432 +0x392 github.com/awesome-gocui/gocui.(*Gui).flush(0xc0000b2b40, 0x0, 0x0) /home/runner/go/pkg/mod/github.com/awesome-gocui/[email protected]/gui.go:477 +0x348 github.com/awesome-gocui/gocui.(*Gui).MainLoop(0xc0000b2b40, 0x24, 0x7ffeefbff7f1) /home/runner/go/pkg/mod/github.com/awesome-gocui/[email protected]/gui.go:426 +0x247 main.runReshCli(0x0, 0x0, 0x0) /home/runner/work/resh/resh/cmd/cli/main.go:167 +0x1418 main.main() /home/runner/work/resh/resh/cmd/cli/main.go:40 +0x26

RESH SEARCH APP failed - sorry for the inconvinience (error output was saved to ~/.resh/cli_last_run_out.txt)

ilyavaiser avatar Sep 14 '21 10:09 ilyavaiser

Can you provide steps to reproduce this?

curusarn avatar Sep 14 '21 14:09 curusarn

Easy, ctrl-r, type "ssh":

ilyas@Ilyas-2020 Remote % panic: runtime error: slice bounds out of range [39:23]

goroutine 1 [running]:
github.com/curusarn/resh/pkg/searchapp.leftCutPadString(0xc0000d4768, 0x17, 0xfffffffffffffff1, 0xc0000d4750, 0x11)
	/home/runner/work/resh/resh/pkg/searchapp/item.go:249 +0x145
github.com/curusarn/resh/pkg/searchapp.ItemColumns.ProduceLine(0xc0000d4750, 0x11, 0xc000483830, 0x8, 0xc00016e500, 0x36, 0xc0007accc0, 0x2d, 0xc0000d4768, 0x17, ...)
	/home/runner/work/resh/resh/pkg/searchapp/item.go:219 +0x59a
main.manager.normalMode(0x7ff7bfeff81d, 0x24, 0x7ff7bfeff849, 0x10, 0x7ff7bfeff860, 0x22, 0x7ff7bfeff895, 0x0, 0xa43, 0x78, ...)
	/home/runner/work/resh/resh/cmd/cli/main.go:517 +0x8fa
main.manager.Layout(0x7ff7bfeff81d, 0x24, 0x7ff7bfeff849, 0x10, 0x7ff7bfeff860, 0x22, 0x7ff7bfeff895, 0x0, 0xa43, 0x78, ...)
	/home/runner/work/resh/resh/cmd/cli/main.go:432 +0x3ea
github.com/awesome-gocui/gocui.(*Gui).flush(0xc0001b0000, 0x0, 0x0)
	/home/runner/go/pkg/mod/github.com/awesome-gocui/[email protected]/gui.go:477 +0x379
github.com/awesome-gocui/gocui.(*Gui).MainLoop(0xc0001b0000, 0x24, 0x7ff7bfeff849)
	/home/runner/go/pkg/mod/github.com/awesome-gocui/[email protected]/gui.go:426 +0x23f
main.runReshCli(0x0, 0x0, 0x0)
	/home/runner/work/resh/resh/cmd/cli/main.go:167 +0x14f6
main.main()
	/home/runner/work/resh/resh/cmd/cli/main.go:40 +0x26
# RESH SEARCH APP failed - sorry for the inconvinience (error output was saved to ~/.resh/cli_last_run_out.txt)

ilyavaiser avatar Oct 21 '21 13:10 ilyavaiser

This is probably connected to UTF-8. I am looking into it.

tivvit avatar Oct 23 '21 15:10 tivvit

Progress report:

  • I am able to reproduce the problem! It happens when the terminal is very small. Leading to negative values passed to leftCutPadString when host is present which causes the mentioned error.
  • leftCutPadString really handles UTF-8 incorrectly

I will try to fix both

tivvit avatar Oct 23 '21 20:10 tivvit

How I can use this? Need to wait for the release? When?

ilyavaiser avatar Nov 25 '21 11:11 ilyavaiser

I will make a new release soon.

curusarn avatar Nov 25 '21 13:11 curusarn

I have just released a new version. Can you try if updating solves your issue? (Run reshctl update and restart your terminal)

curusarn avatar Nov 26 '21 20:11 curusarn

This should be solved, I guess we may re-open if it is not.

tivvit avatar Oct 15 '22 12:10 tivvit

Closing. Feel free to reopen if the issue persists.

curusarn avatar Dec 31 '22 12:12 curusarn