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 on FreeBSD host #235

Open
aleksuss opened this issue Apr 13, 2021 · 5 comments
Open

Panic on FreeBSD host #235

aleksuss opened this issue Apr 13, 2021 · 5 comments

Comments

@aleksuss
Copy link

Hello. I get a panic while trying to run demo:

$ go run _demos/keyboard.go
panic: runtime error: index out of range [15] with length 14
	panic: runtime error: index out of range [14] with length 14

goroutine 1 [running]:
github.com/nsf/termbox-go.Close()
	/home/oleksandr.anyshchenko/termbox-go/api.go:146 +0x4d2
panic(0x4fc5c0, 0xc0000de000)
	/usr/local/go/src/runtime/panic.go:965 +0x1b9
github.com/nsf/termbox-go.SetInputMode(0x5, 0x0)
	/home/oleksandr.anyshchenko/termbox-go/api.go:483 +0x1e5
main.main()
	/home/oleksandr.anyshchenko/termbox-go/_demos/keyboard.go:702 +0x7d
exit status 2

FreeBSD 12.2
Go 1.16.3

@dchapes
Copy link

dchapes commented May 9, 2021

This was fixed in PR #236 by @ncw and merged in 2ff6302 by @scrouthtv.
There hasn't been a tagged released since then, nor has the broken v1.1.0 been retracted.
If you have a module using termbox, I'd suggest adding something like the following to your module's go.mod:

require github.com/nsf/termbox-go v1.1.1-0.20210421210813-2ff630277754

// termbox-go v1.1.0 panics, see https://github.com/nsf/termbox-go/pull/236
exclude github.com/nsf/termbox-go v1.1.0

You can add those lines by hand or safely adjust your existing go.mod (other than the comment) with:

cd $somewhere_within_your_own_termbox_requiring_module
go get github.com/nsf/termbox-go@2ff630277754
go mod edit -exclude=github.com/nsf/termbox-go@v1.1.0
[Edit/Update:] v1.1.1 has been tagged, in your `go.mod` replace the above @2ff630277754 with @v1.1.1 instead. E.g. 
require github.com/nsf/termbox-go v1.1.1
exclude github.com/nsf/termbox-go v1.1.0

or just run:

go mod edit -exclude=github.com/nsf/termbox-go@v1.1.0
go get github.com/nsf/termbox-go@latest

[/edit]

The exclude line is to prevent any accidental go get -u, go get github.com/nsf/termbox-go@latest, or similar command that anyone runs from within/under your module from going back to the broken v1.1.0 (which Go will tend to do automatically until the next higher compatible version is tagged).

@scrouthtv
Copy link
Collaborator

Give me 10 minutes and I'll tag it.. Looks like I messed that up by a lot

@scrouthtv
Copy link
Collaborator

scrouthtv commented May 9, 2021

Kindly try v1.1.1

@dchapes should I completely delete the v1.1.0 tag?

@dchapes
Copy link

dchapes commented May 9, 2021

Kindly try v1.1.1

Thanks!

@dchapes should I completely delete the v1.1.0 tag?

My understanding is that no, once anyone could have seen a version and it could have gotten into proxy.golang.org then that version should always exist without any changes or "bad-things" will happen (e.g. existing repeatable builds could break if they can't retrieve that version from a proxy).

Instead you could retract that version as per the Go module documentation https://golang.org/ref/mod#go-mod-file-retract (e.g. add a line like retract v1.1.0 // some-reason-for-the-retraction to go.mod).

That would make all the Go commands ignore that version by default (unless explicitly asked, e.g. go list -m -versions -retracted github.com/nsf/termbox-go). Ideally, you'd have made that change to go.mod before you tagged v1.1.1 since retraction lines in go.mod are read from the latest tagged version.

Since you didn't do that (no big deal), I'd probably just edit go.mod to retract v1.1.0 now (just so it's not forgotten about), but leave that change to become visible whenever the next version happens to gets tagged. The alternative would be to make yet another tagged patch release, e.g. something like v1.1.2 with just the go.mod change but that's probably overkill and unneeded tag noise since with the new v1.1.1 anybody not explicitly asking for or depending on v1.1.0 won't get it.
[Note: this only makes any difference at all for users of Go1.16+; Go1.15 and lower will ignore the retract directive anyway; another reason for not bothering to make another tag until needed for other changes.]
The issue was that until you did the v1.1.1 tag there was a landmine awaiting anyone doing a go get -u or go get github.com/nsf/termbox-go@latest (or even just go get github.com/nsf/termbox-go if they didn't already have a require directive for it) since it would get the broken version; now all those commands will get a working version so the landmine is already defused :). Thanks again.

[Edit: By the way, I just verified that as expected, the command the OP tried, go run _demos/keyboard.go does indeed work with v1.1.1 on FreeBSD so unless something else is broken for the OP then I think this issue can be closed.]

@scrouthtv
Copy link
Collaborator

scrouthtv commented May 9, 2021

I'd probably just edit go.mod to retract v1.1.0 now

Done - 8f994c

Go1.15 and lower will ignore the retract directive anyway

Ooh that's why I never heard of it before, thanks for teaching me something new :)

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

No branches or pull requests

3 participants