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

Bug: nil pointer #38

Closed
Davincible opened this issue Nov 13, 2022 · 4 comments · Fixed by #40
Closed

Bug: nil pointer #38

Davincible opened this issue Nov 13, 2022 · 4 comments · Fixed by #40

Comments

@Davincible
Copy link

Caught panic:

runtime error: invalid memory address or nil pointer dereference

Restoring terminal...

goroutine 1 [running]:
runtime/debug.Stack()
        /usr/lib/go/src/runtime/debug/stack.go:24 +0x65
runtime/debug.PrintStack()
        /usr/lib/go/src/runtime/debug/stack.go:16 +0x19
github.com/charmbracelet/bubbletea.(*Program).StartReturningModel.func3()
        /home/tyler/go/pkg/mod/github.com/charmbracelet/[email protected]/tea.go:350 +0x95
panic({0x52c720, 0x660ae0})
        /usr/lib/go/src/runtime/panic.go:1047 +0x266
github.com/charmbracelet/bubbles/list.(*Model).updatePagination(0xc00011ac80)
        /home/tyler/go/pkg/mod/github.com/charmbracelet/[email protected]/list/list.go:656 +0x2d1
github.com/charmbracelet/bubbles/list.(*Model).SetItems(0xc00011ac80, {0xc000110500, 0x4, 0x4})
        /home/tyler/go/pkg/mod/github.com/charmbracelet/[email protected]/list/list.go:293 +0x108
github.com/orlangure/gocovsh/internal/model.(*Model).onProfilesLoaded(0xc00011ac80, {0xc000070540, 0x4, 0x0})
        /home/tyler/go/pkg/mod/github.com/orlangure/[email protected]/internal/model/model.go:210 +0x2db
github.com/orlangure/gocovsh/internal/model.(*Model).Update(0xc00011ac80, {0x522f40, 0xc00000c0f0})
        /home/tyler/go/pkg/mod/github.com/orlangure/[email protected]/internal/model/model.go:100 +0x308
github.com/charmbracelet/bubbletea.(*Program).StartReturningModel(0xc000138180)
        /home/tyler/go/pkg/mod/github.com/charmbracelet/[email protected]/tea.go:534 +0x139c
github.com/charmbracelet/bubbletea.(*Program).Start(...)
        /home/tyler/go/pkg/mod/github.com/charmbracelet/[email protected]/tea.go:543
github.com/orlangure/gocovsh/internal/program.(*Program).Run(0xc0001280b0)
        /home/tyler/go/pkg/mod/github.com/orlangure/[email protected]/internal/program/program.go:116 +0x36c
main.main()
        /home/tyler/go/pkg/mod/github.com/orlangure/[email protected]/main.go:21 +0x119
@orlangure
Copy link
Owner

Hi @Davincible and thank you for the report. I think this is a known issue in an underlying library. @bashbunni, was it the issue you experienced before?

@muesli
Copy link
Contributor

muesli commented Nov 16, 2022

This is caused by a bit of a race condition: Model.list doesn't get properly initialized until Model.updateWindowSize gets called. In some situations onProfilesLoaded can arrive before the terminal dimensions have been retrieved however, and calling it will call updatePagination which accesses the still uninitialized (nil) item delegate.

I'll provide a fix in a moment.

@bashbunni
Copy link
Contributor

@orlangure yeah this looks exactly like the error I was facing

muesli added a commit to muesli/gocovsh that referenced this issue Nov 16, 2022
Model.list didn't get properly initialized until
Model.updateWindowSize got called. In some situations
onProfilesLoaded can arrive before the terminal dimensions have
been retrieved however, and calling it will call updatePagination
which accesses the still uninitialized (nil) item delegate. This
causes a crash.

Fixes orlangure#38.
orlangure pushed a commit that referenced this issue Nov 17, 2022
Model.list didn't get properly initialized until
Model.updateWindowSize got called. In some situations
onProfilesLoaded can arrive before the terminal dimensions have
been retrieved however, and calling it will call updatePagination
which accesses the still uninitialized (nil) item delegate. This
causes a crash.

Fixes #38.
@Davincible
Copy link
Author

Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants