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: unknown tcell event type: <nil> #339

Open
kmulvey opened this issue Oct 14, 2022 · 1 comment
Open

panic: unknown tcell event type: <nil> #339

kmulvey opened this issue Oct 14, 2022 · 1 comment
Labels
question Further information is requested

Comments

@kmulvey
Copy link

kmulvey commented Oct 14, 2022

I get this error every time I try to quit (by pressing 'q'). It also leaves the terminal window in an unusable state. Where do i start debugging this? The stack trace doesnt even list any of my code.

       quitter := func(k *terminalapi.Keyboard) {
           if k.Key == 'q' || k.Key == 'Q' {
               term.Close()
           }
       }

Full code is here: https://github.com/kmulvey/text2speech/blob/main/dashboard.go

panic: unknown tcell event type: <nil>

goroutine 59 [running]:
github.com/mum4k/termdash.(*termdash).handleError(...)
	/opt/code/go/pkg/mod/github.com/mum4k/termdash@v0.17.0/termdash.go:252
github.com/mum4k/termdash.(*termdash).subscribers.func1({0xb61960?, 0xc000118010?})
	/opt/code/go/pkg/mod/github.com/mum4k/termdash@v0.17.0/termdash.go:215 +0xd2
github.com/mum4k/termdash/private/event.(*subscriber).callback(0xc00007e2c0, {0xb61960?, 0xc000118010?})
	/opt/code/go/pkg/mod/github.com/mum4k/termdash@v0.17.0/private/event/event.go:95 +0x31
github.com/mum4k/termdash/private/event.(*subscriber).run(0xc00007e2c0, {0xb66b18, 0xc00007e200})
	/opt/code/go/pkg/mod/github.com/mum4k/termdash@v0.17.0/private/event/event.go:110 +0x5a
created by github.com/mum4k/termdash/private/event.newSubscriber
	/opt/code/go/pkg/mod/github.com/mum4k/termdash@v0.17.0/private/event/event.go:89 +0x205
@mum4k
Copy link
Owner

mum4k commented Oct 18, 2022

I think the problem here is an invalid order of termination. The implemented quitter calls term.Close() thus closing the terminal object that was given to Termdash for use. This breaks the lifetime guarantee - objects given to called functions must outlive those function calls.

What happens is that the term object shuts down and becomes invalid. But there is some concurrency that still attempts to use it via termdash, probably in one of those goroutines.

The solution is to make sure that termdash and all goroutines are correctly terminated before the term object gets closed. Termination should be done in the exact opposite order of construction.

You can look at the demos for an example of a correct termination sequence, e.g. the termdashdemo:

https://github.com/mum4k/termdash/blob/master/termdashdemo/termdashdemo.go

@mum4k mum4k added the question Further information is requested label Oct 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants