joshmedeski / sesh

Smart session manager for the terminal
MIT License
417 stars 17 forks source link

Panic in sesh/tmux/list.go running sesh list -t #34

Closed RobertMenkeAgilebits closed 5 months ago

RobertMenkeAgilebits commented 5 months ago

Thanks for the hard work on this package!

I'm trying to configure my dev environment with multiple tmux sessions orchestrated using tmuxinator. I've simplified the environment to 2 sessions to illustrate the issue. Running sesh list -t panics with an NPE.

As far as I can tell, tmuxinator isn't doing anything particularly out of the ordinary when creating a session https://github.com/search?q=repo:tmuxinator/tmuxinator%20new-session&type=code.

Here's a text version of the stack trace

❯ sesh list -t
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x1045a2bcc]

goroutine 1 [running]:
github.com/joshmedeski/sesh/tmux.List.func1(0x30?, 0x1047ddec0?)
    /home/runner/work/sesh/sesh/tmux/list.go:150 +0x3c
sort.insertionSort_func({0x140000f9460?, 0x140000c5360?}, 0x0, 0x2)
    /opt/hostedtoolcache/go/1.21.5/x64/src/sort/zsortfunc.go:12 +0xc0
sort.pdqsort_func({0x140000f9460?, 0x140000c5360?}, 0x18?, 0x1047ddec0?, 0x140000b0420?)
    /opt/hostedtoolcache/go/1.21.5/x64/src/sort/zsortfunc.go:73 +0x260
sort.Slice({0x104671d20?, 0x140000b0420?}, 0x2?)
    /opt/hostedtoolcache/go/1.21.5/x64/src/sort/slice.go:26 +0xfc
github.com/joshmedeski/sesh/tmux.List()
    /home/runner/work/sesh/sesh/tmux/list.go:149 +0x768
github.com/joshmedeski/sesh/session.List({0x18?, 0x0?})
    /home/runner/work/sesh/sesh/session/list.go:17 +0x6c
github.com/joshmedeski/sesh/seshcli.App.List.func1(0x1400012c000?)
    /home/runner/work/sesh/sesh/cmds/list.go:31 +0x50
github.com/urfave/cli/v2.(*Command).Run(0x1400012c000, 0x140000a84c0, {0x140000c49c0, 0x2, 0x2})
    /home/runner/go/pkg/mod/github.com/urfave/cli/v2@v2.27.0/command.go:279 +0x754
github.com/urfave/cli/v2.(*Command).Run(0x1400012c6e0, 0x140000a8380, {0x1400009c090, 0x3, 0x3})
    /home/runner/go/pkg/mod/github.com/urfave/cli/v2@v2.27.0/command.go:272 +0x964
github.com/urfave/cli/v2.(*App).RunContext(0x14000128000, {0x1046aaf48?, 0x104811420}, {0x1400009c090, 0x3, 0x3})
    /home/runner/go/pkg/mod/github.com/urfave/cli/v2@v2.27.0/app.go:337 +0x534
github.com/urfave/cli/v2.(*App).Run(0x10460ed68?, {0x1400009c090?, 0x0?, 0x0?})
    /home/runner/go/pkg/mod/github.com/urfave/cli/v2@v2.27.0/app.go:311 +0x3c
main.main()
    /home/runner/work/sesh/sesh/main.go:14 +0xb0

CleanShot 2024-01-20 at 15 21 19@2x

joshmedeski commented 5 months ago

Thanks for flagging this. I had to skip sorting by last attached if the session hadn't been attached to yet.

Fixed in v0.6.1