Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic: index out of range [0] with length 0 #2466

Closed
mycrEEpy opened this issue Jan 11, 2024 · 11 comments
Closed

Panic: index out of range [0] with length 0 #2466

mycrEEpy opened this issue Jan 11, 2024 · 11 comments
Labels
bug Something isn't working question Further information is requested

Comments

@mycrEEpy
Copy link
Contributor




Describe the bug
When trying to navigate through the tables sometimes k9s panics with an index out of range error.

To Reproduce

It's probably not at random, but I'm currently unable to find reproducible actions.

Historical Documents
Logs:

11:39AM ERR Boom! runtime error: index out of range [0] with length 0
11:39AM ERR goroutine 1 [running]:
runtime/debug.Stack()
	runtime/debug/stack.go:24 +0x5e
github.com/derailed/k9s/cmd.run.func2()
	github.com/derailed/k9s/cmd/root.go:84 +0xa5
panic({0x4ab7340?, 0xc007f590f8?})
	runtime/panic.go:914 +0x21f
github.com/derailed/tview.(*Application).Run.func1()
	github.com/derailed/tview@v0.8.2/application.go:243 +0x45
panic({0x4ab7340?, 0xc007f590f8?})
	runtime/panic.go:914 +0x21f
github.com/derailed/tview.(*TextView).reindexBuffer(0xc000ca99e0, 0x9c)
	github.com/derailed/tview@v0.8.2/textview.go:901 +0xef0
github.com/derailed/tview.(*TextView).Draw(0xc000ca99e0, {0x58a3ad0?, 0xc0008d5200})
	github.com/derailed/tview@v0.8.2/textview.go:991 +0x173
github.com/derailed/tview.(*Flex).Draw(0xc000ddc240, {0x58a3ad0?, 0xc0008d5200})
	github.com/derailed/tview@v0.8.2/flex.go:211 +0x386
github.com/derailed/tview.(*Pages).Draw(0xc000b90360, {0x58a3ad0, 0xc0008d5200})
	github.com/derailed/tview@v0.8.2/pages.go:300 +0xce
github.com/derailed/tview.(*Application).draw(0xc0002387e0)
	github.com/derailed/tview@v0.8.2/application.go:597 +0x13a
github.com/derailed/tview.(*Application).Run(0xc0002387e0)
	github.com/derailed/tview@v0.8.2/application.go:343 +0x549
github.com/derailed/k9s/internal/view.(*App).Run(0xc0003a0480)
	github.com/derailed/k9s/internal/view/app.go:548 +0x8f
github.com/derailed/k9s/cmd.run(0xc000209a00?, {0x4cfd0bf?, 0x4?, 0x4cfcfd3?})
	github.com/derailed/k9s/cmd/root.go:102 +0x365
github.com/spf13/cobra.(*Command).execute(0x76adfe0, {0xc0001182e0, 0x2, 0x2})
	github.com/spf13/cobra@v1.8.0/command.go:983 +0xabc
github.com/spf13/cobra.(*Command).ExecuteC(0x76adfe0)
	github.com/spf13/cobra@v1.8.0/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
	github.com/spf13/cobra@v1.8.0/command.go:1039
github.com/derailed/k9s/cmd.Execute(...)
	github.com/derailed/k9s/cmd/root.go:59
main.main()
	github.com/derailed/k9s/main.go:32 +0x1b

Expected behavior

Navigating through tables should not panic the application.

Versions (please complete the following information):

  • OS: Ubuntu 22.04
  • K9s: 0.31.2
  • K8s: 1.28.4
@hc2p
Copy link

hc2p commented Jan 11, 2024

For me k9s crashes with a similar errror when i use search, e.g. within a decoded secret with longer text.

Boom!! runtime error: index out of range [16] with length 0.

No stacktrace though.

@derailed derailed added bug Something isn't working question Further information is requested labels Jan 11, 2024
@derailed
Copy link
Owner

@hc2p Can't seem to repro here at the ranch ;(
Could you add more details on the search prompt you'd entered or content snippets?
Thank you!

@hc2p
Copy link

hc2p commented Jan 12, 2024

It does not correlate with the search prompt nor content. But as of now i only have seen it when searching through secrets. On "bigger" secrets it crashes quite instantly. With "smaller" ones it takes a while, and usually seems to work fine.
That's the logs:

9:39AM ERR Boom! runtime error: index out of range [4] with length 0
9:39AM ERR goroutine 1 [running]:
runtime/debug.Stack()
	runtime/debug/stack.go:24 +0x5e
github.com/derailed/k9s/cmd.run.func2()
	github.com/derailed/k9s/cmd/root.go:84 +0xa5
panic({0x10336b100?, 0xc003b9bb60?})
	runtime/panic.go:914 +0x21f
github.com/derailed/tview.(*Application).Run.func1()
	github.com/derailed/tview@v0.8.2/application.go:243 +0x45
panic({0x10336b100?, 0xc003b9bb60?})
	runtime/panic.go:914 +0x21f
github.com/derailed/tview.(*TextView).Draw(0xc000fbd9e0, {0x104155b50?, 0xc001c2bb00})
	github.com/derailed/tview@v0.8.2/textview.go:1074 +0xc8d
github.com/derailed/tview.(*Flex).Draw(0xc00100eba0, {0x104155b50?, 0xc001c2bb00})
	github.com/derailed/tview@v0.8.2/flex.go:207 +0x330
github.com/derailed/tview.(*Pages).Draw(0xc000efbad0, {0x104155b50, 0xc001c2bb00})
	github.com/derailed/tview@v0.8.2/pages.go:300 +0xce
github.com/derailed/tview.(*Flex).Draw(0xc0010ea300, {0x104155b50?, 0xc001c2bb00})
	github.com/derailed/tview@v0.8.2/flex.go:207 +0x330
github.com/derailed/tview.(*Pages).Draw(0xc000efb800, {0x104155b50, 0xc001c2bb00})
	github.com/derailed/tview@v0.8.2/pages.go:300 +0xce
github.com/derailed/tview.(*Application).draw(0xc000e982a0)
	github.com/derailed/tview@v0.8.2/application.go:597 +0x13a
github.com/derailed/tview.(*Application).Run(0xc000e982a0)
	github.com/derailed/tview@v0.8.2/application.go:343 +0x549
github.com/derailed/k9s/internal/view.(*App).Run(0xc0002a7920)
	github.com/derailed/k9s/internal/view/app.go:548 +0x8f
github.com/derailed/k9s/cmd.run(0xc000b35800?, {0x1035b0aee?, 0x4?, 0x1035b0a0a?})
	github.com/derailed/k9s/cmd/root.go:102 +0x3c5
github.com/spf13/cobra.(*Command).execute(0x1061d0940, {0xc0001182e0, 0x2, 0x2})
	github.com/spf13/cobra@v1.8.0/command.go:983 +0xabc
github.com/spf13/cobra.(*Command).ExecuteC(0x1061d0940)
	github.com/spf13/cobra@v1.8.0/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
	github.com/spf13/cobra@v1.8.0/command.go:1039
github.com/derailed/k9s/cmd.Execute(...)
	github.com/derailed/k9s/cmd/root.go:59
main.main()
	github.com/derailed/k9s/main.go:32 +0x1b
	```

@BLaDZer
Copy link

BLaDZer commented Jan 12, 2024

Same or almost same error here:

Ubuntu 22.04, amd64

K9s Rev: v0.0.0 ⚡️v0.31.4
K8s Rev: v1.27.3-gke.100

�[90m11:23AM�[0m �[32mINF�[0m 🐶 K9s starting up...
�[90m11:23AM�[0m �[32mINF�[0m ✅ Kubernetes connectivity
�[90m11:25AM�[0m �[1m�[31mERR�[0m�[0m Watcher failed for containers -- pods "<private>" not found �[36merror=�[0m�[31m"pods \"<private>\" not found"�[0m
�[90m11:28AM�[0m �[1m�[31mERR�[0m�[0m Boom! runtime error: index out of range [0] with length 0
�[90m11:28AM�[0m �[1m�[31mERR�[0m�[0m goroutine 1 [running]:
runtime/debug.Stack()
	/usr/lib/go-1.21/src/runtime/debug/stack.go:24 +0x5e
github.com/derailed/k9s/cmd.run.func2()
	/home/dev/go/pkg/mod/github.com/derailed/k9s@v0.31.2/cmd/root.go:84 +0xa5
panic({0x4aa91a0?, 0xc00c75b5a8?})
	/usr/lib/go-1.21/src/runtime/panic.go:914 +0x21f
github.com/derailed/tview.(*Application).Run.func1()
	/home/dev/go/pkg/mod/github.com/derailed/tview@v0.8.2/application.go:243 +0x45
panic({0x4aa91a0?, 0xc00c75b5a8?})
	/usr/lib/go-1.21/src/runtime/panic.go:914 +0x21f
github.com/derailed/k9s/internal/render.RowEventSorter.Less({{0xc00bca5200, 0x14, 0x20}, 0x0, {0x58036b8, 0x1}, 0x0, 0x0, 0x0, 0x1}, ...)
	/home/dev/go/pkg/mod/github.com/derailed/k9s@v0.31.2/internal/render/row_event.go:240 +0xf2
sort.order2(...)
	/usr/lib/go-1.21/src/sort/zsortinterface.go:299
sort.median({0x5841640, 0xc00c8e66c0}, 0x5, 0xa, 0xf, 0xc00bcb50c0)
	/usr/lib/go-1.21/src/sort/zsortinterface.go:308 +0x3c
sort.choosePivot({0x5841640?, 0xc00c8e66c0?}, 0x5?, 0xc00098db38?)
	/usr/lib/go-1.21/src/sort/zsortinterface.go:284 +0x165
sort.pdqsort({0x5841640, 0xc00c8e66c0}, 0xc00098da01?, 0xc00c8e66c0?, 0xc004f9b1f0?)
	/usr/lib/go-1.21/src/sort/zsortinterface.go:89 +0xcb
sort.Sort({0x5841640, 0xc00c8e66c0})
	/usr/lib/go-1.21/src/sort/sort.go:51 +0x54
github.com/derailed/k9s/internal/render.RowEvents.Sort({0xc00bca5200?, 0x0?, 0x0?}, {0x58036b8?, 0xc00037a960?}, 0x300000000?, 0xb8?, 0x12?, 0x24?, 0x1)
	/home/dev/go/pkg/mod/github.com/derailed/k9s@v0.31.2/internal/render/row_event.go:213 +0x9a
github.com/derailed/k9s/internal/ui.(*Table).doUpdate(0xc00037a960, 0xc00c680480)
	/home/dev/go/pkg/mod/github.com/derailed/k9s@v0.31.2/internal/ui/table.go:262 +0xa37
github.com/derailed/k9s/internal/ui.(*Table).Filter(0xc00037a960, {0xc000f1fde0?, 0x0?})
	/home/dev/go/pkg/mod/github.com/derailed/k9s@v0.31.2/internal/ui/table.go:158 +0x5c
github.com/derailed/k9s/internal/view.(*Table).BufferCompleted.func1()
	/home/dev/go/pkg/mod/github.com/derailed/k9s@v0.31.2/internal/view/table.go:163 +0x25
github.com/derailed/k9s/internal/ui.(*App).QueueUpdateDraw.func1.(*Application).QueueUpdateDraw.func1()
	/home/dev/go/pkg/mod/github.com/derailed/tview@v0.8.2/application.go:731 +0x23
github.com/derailed/tview.(*Application).Run(0xc00023ea80)
	/home/dev/go/pkg/mod/github.com/derailed/tview@v0.8.2/application.go:376 +0x8a2
github.com/derailed/k9s/internal/view.(*App).Run(0xc000337140)
	/home/dev/go/pkg/mod/github.com/derailed/k9s@v0.31.2/internal/view/app.go:548 +0x8f
github.com/derailed/k9s/cmd.run(0xc000950000?, {0x4cee65b?, 0x4?, 0x4cee56f?})
	/home/dev/go/pkg/mod/github.com/derailed/k9s@v0.31.2/cmd/root.go:102 +0x365
github.com/spf13/cobra.(*Command).execute(0x7690300, {0xc0000520b0, 0x0, 0x0})
	/home/dev/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:983 +0xabc
github.com/spf13/cobra.(*Command).ExecuteC(0x7690300)
	/home/dev/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
	/home/dev/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1039
github.com/derailed/k9s/cmd.Execute(...)
	/home/dev/go/pkg/mod/github.com/derailed/k9s@v0.31.2/cmd/root.go:59
main.main()
	/home/dev/go/pkg/mod/github.com/derailed/k9s@v0.31.2/main.go:32 +0x1b

@derailed
Copy link
Owner

@BLaDZer This looks like a different issue. Did this occur while in container view?

@derailed
Copy link
Owner

@hc2p Thank you for the details! By bigger secrets do you mean listing out secrets and filtering thru this list?
How many secrets are you trying to load up? or am I missing it??

@hc2p
Copy link

hc2p commented Jan 12, 2024

@derailed by big secrets i mean one secret with a rather long payload, which i open using decode/x and then search through.
In this case it's a cloud-init file.

derailed added a commit that referenced this issue Jan 12, 2024
@derailed
Copy link
Owner

@hc2p Big THANK YOU in full effect to you Hannes for the remainder of the week!
This has been a bug lurking for a while on this repo with no repro in sight ;(

I think I've found the issue?? and lassoing in a perf boost too as a bonus.
As customary, I excel at making the wrong things very fast!
So please double check me on this ding dang deal and keep your eyes peeled around this feature just in case ;)
v0.31.5... coming up!

@hc2p
Copy link

hc2p commented Jan 12, 2024

That's great to hear! Glad I could help:)

Thanks for keeping up the work on this wonderful tool!

@mycrEEpy
Copy link
Contributor Author

Thanks! Will keep my eyes open :)

@BLaDZer
Copy link

BLaDZer commented Jan 15, 2024

@derailed I don't remember exactly, but it's quite possible. I'm also happy to test the new release.

thejoeejoee pushed a commit to thejoeejoee/k9s that referenced this issue Feb 23, 2024
placintaalexandru pushed a commit to placintaalexandru/k9s that referenced this issue Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants