murex icon indicating copy to clipboard operation
murex copied to clipboard

murex panic: runtime error: index out of range [0] with length 0

Open notjames opened this issue 1 year ago • 2 comments

Describe the bug: Might be related to #788

at 15:06:18 via  v3.1.4 ❯ cd $panic: runtime error: index out of range [0] with length 0
Change directory: /home/me/$                                                                                                                                                                                                                                                                                                                             
goroutine 8762 [running]:
github.com/lmorg/murex/utils.NormalisePath({0x0, 0x0})
        /home/me/go/pkg/mod/github.com/lmorg/[email protected]/utils/path_posix.go:17 +0x8b
github.com/lmorg/murex/shell.hintText({0xc0036b8000, 0x5, 0x100000}, 0xc001234460?)
        /home/me/go/pkg/mod/github.com/lmorg/[email protected]/shell/hint.go:32 +0x12c
github.com/lmorg/murex/utils/readline.(*Instance).getHintText(0xc0001f7500)
        /home/me/go/pkg/mod/github.com/lmorg/[email protected]/utils/readline/hint.go:17 +0xf2
github.com/lmorg/murex/utils/readline.(*Instance).updateHelpersStr(0xc0001f7500)
        /home/me/go/pkg/mod/github.com/lmorg/[email protected]/utils/readline/write.go:208 +0x25
github.com/lmorg/murex/utils/readline.(*Instance).insertStr(0xc0001f7500, {0xc003ab8000?, 0x1?, 0x4?})
        /home/me/go/pkg/mod/github.com/lmorg/[email protected]/utils/readline/update.go:37 +0x505
github.com/lmorg/murex/utils/readline.(*Instance).readlineInputStr(0xc0001f7500, {0xc003ab8000?, 0xc000358048?, 0x1?})
        /home/me/go/pkg/mod/github.com/lmorg/[email protected]/utils/readline/readline.go:552 +0x116
github.com/lmorg/murex/utils/readline.(*Instance).Readline(0xc0001f7500)
        /home/me/go/pkg/mod/github.com/lmorg/[email protected]/utils/readline/readline.go:319 +0x1dd9
github.com/lmorg/murex/shell.showPrompt()
        /home/me/go/pkg/mod/github.com/lmorg/[email protected]/shell/shell.go:183 +0x493
created by github.com/lmorg/murex/shell.Start in goroutine 1
        /home/me/go/pkg/mod/github.com/lmorg/[email protected]/shell/shell.go:100 +0x316

Expected behaviour: I expected to be able to change directory successfully without a stacktrace and a closing of the shell.

Screenshots: N/A

Platform (please complete the following information):

  • OS, output from uname -a if supported: Ubuntu 22.04 LTS
  • Terminal Emulator: [e.g. iTerm2, Konsole]: Tilix via tmux
  • Murex version, output from version --no-app-name: [e.g. 2.12.1200] : 5.3.7000

Additional context tmux version is: 3.2a

notjames avatar Jan 25 '24 23:01 notjames

That's interesting. It is "impossible" for the function that is raising that panic to have a zero length array so I don't know how Murex got into that state. Might be related to the cache, as you said. That seems likely possibility. Either way, it's a very easy fix, I just need to do a quick bounds check (the only reason I didn't was because there "shouldn't" have been a situation that array would be zero length).

Thanks for the bug report.

I'd be interested to hear your thoughts on Murex aside from these two bugs

lmorg avatar Jan 29 '24 20:01 lmorg

@notjames pushed a fix to develop

lmorg avatar Jan 31 '24 15:01 lmorg