nsf / termbox-go

Pure Go termbox implementation
http://godoc.org/github.com/nsf/termbox-go
MIT License
4.66k stars 372 forks source link

Fix crashes and odd behaviour due to builtin terminfo inconsistencies #236

Closed ncw closed 3 years ago

ncw commented 3 years ago

In recent commits

3 more attributes were added - hidden, dim and cursive.

Unfortunately these commits didn't adjust the builtin terminfo.

This leads to crashes which look like this on quit

panic: runtime error: index out of range [14] with length 14
goroutine 1 [running]:
github.com/nsf/termbox-go.Close()
    github.com/nsf/termbox-go@v1.1.0/api.go:146 +0x458

And other odd behaviour like arrow keys not being recognised.

This patch fixes the terminfo, and names all the entries to make it easier to update. It also adds a test to make sure the terminfo doesn't get out of sync again.

See: https://github.com/rclone/rclone/issues/5259

ncw commented 3 years ago

Ooops missed one - fixed now.

scrouthtv commented 3 years ago

Looks good!

dchapes commented 3 years ago

I recently ran into this as well and had downgraded to v1.0.0 to avoid it. Since this issue effectively breaks v1.1.0 completely for me (my program wouldn't even start without a panic with v1.1) I've also added:

exclude github.com/nsf/termbox-go v1.1.0

to my go.mod. Could you perhaps tag the current version v1.1.1 so I don't need to require a pseudo-version?

If I were you, I'd also consider retracting the severely broken version to help prevent others from running into this. E.g. by adding something like the following to termbox's go.mod:

retract v1.1.0 // Broken; panic: runtime error: index out of range [14] with length 14

But perhaps this issue isn't as severe for others as it was in my program.

Thanks very much for the fix @ncw !

scrouthtv commented 3 years ago

I just tagged the fixed version as v1.1.1, sorry for the inconvenience.