lmorg / murex

A smarter shell and scripting environment with advanced features designed for usability, safety and productivity (eg smarter DevOps tooling)
https://murex.rocks
GNU General Public License v2.0
1.46k stars 27 forks source link

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

Closed notjames closed 7 months ago

notjames commented 8 months ago

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/murex@v0.0.0-20240106220041-ce7969fbd772/utils/path_posix.go:17 +0x8b
github.com/lmorg/murex/shell.hintText({0xc0036b8000, 0x5, 0x100000}, 0xc001234460?)
        /home/me/go/pkg/mod/github.com/lmorg/murex@v0.0.0-20240106220041-ce7969fbd772/shell/hint.go:32 +0x12c
github.com/lmorg/murex/utils/readline.(*Instance).getHintText(0xc0001f7500)
        /home/me/go/pkg/mod/github.com/lmorg/murex@v0.0.0-20240106220041-ce7969fbd772/utils/readline/hint.go:17 +0xf2
github.com/lmorg/murex/utils/readline.(*Instance).updateHelpersStr(0xc0001f7500)
        /home/me/go/pkg/mod/github.com/lmorg/murex@v0.0.0-20240106220041-ce7969fbd772/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/murex@v0.0.0-20240106220041-ce7969fbd772/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/murex@v0.0.0-20240106220041-ce7969fbd772/utils/readline/readline.go:552 +0x116
github.com/lmorg/murex/utils/readline.(*Instance).Readline(0xc0001f7500)
        /home/me/go/pkg/mod/github.com/lmorg/murex@v0.0.0-20240106220041-ce7969fbd772/utils/readline/readline.go:319 +0x1dd9
github.com/lmorg/murex/shell.showPrompt()
        /home/me/go/pkg/mod/github.com/lmorg/murex@v0.0.0-20240106220041-ce7969fbd772/shell/shell.go:183 +0x493
created by github.com/lmorg/murex/shell.Start in goroutine 1
        /home/me/go/pkg/mod/github.com/lmorg/murex@v0.0.0-20240106220041-ce7969fbd772/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):

Additional context tmux version is: 3.2a

lmorg commented 8 months ago

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 commented 8 months ago

@notjames pushed a fix to develop