mirror of
https://github.com/rivo/tview.git
synced 2026-04-26 21:35:54 +03:00
[GH-ISSUE #166] Crashing in goroutine causes terminal to become unresponsive #132
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#132
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @JesseAldridge on GitHub (Sep 11, 2018).
Original GitHub issue: https://github.com/rivo/tview/issues/166
@rivo commented on GitHub (Sep 11, 2018):
I tried your source code and it didn't become unresponsive for me (on a Mac). Ctrl-C still stops the program as expected.
A panic in a goroutine will just crash that goroutine. If you want
tviewto react to a panic (usually, this means shutting down the application), you'll need to propagate the panic to the main goroutine.This is not really an issue with
tviewbut rather Go's general behaviour. I'll close this for now but will reopen in case we do identify anything that needs to be done intview.@JesseAldridge commented on GitHub (Sep 11, 2018):
Not sure I'm understanding. Here is a gif that will hopefully clarify:

It looks like the issue is actually not that the terminal becomes unresponsive, but that input stops rendering. In that gif I ran the code above (with the bad imports removed), after it crashes I hit a bunch of random keys. Then I type
echo "hello". The keystrokes are apparently still being processed by bash, but just not rendering properly. Hitting Ctrl-C doesn't remedy the situation.So you're saying that after the goroutine crashes the tview gui should continue functioning? That appears not to have happened in my case.
@JesseAldridge commented on GitHub (Sep 11, 2018):
I'm also on a mac. High Sierra with iterm2.
@rivo commented on GitHub (Sep 11, 2018):
I didn't say the
tviewGUI should continue functioning. In fact, I would say you should try to avoid panics in goroutines as the result will be undefined, as you can see. Go writes to stderr when it panics. I don't know how this affects the terminal session but obviously it doesn't in a good way.You may be able to recover from this by running the
resetcommand.@JesseAldridge commented on GitHub (Sep 12, 2018):
Yeah looks like I just need to call
app.Stop()andrecoverfrom the goroutine.This works well:
@rivo commented on GitHub (Sep 25, 2018):
Yes, this should be a good way of dealing with it. I think you can even print the panic's callstack after
app.Stop().