-
Notifications
You must be signed in to change notification settings - Fork 374
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: runtime error: slice bounds out of range #166
Comments
Same problem |
I sometimes run into this issue using
|
Did anyone solve this problem? I got the same problem when i using |
I still see this from time to time, unfortunately it is not very easy to reproduce. It happens when I navigate through a list with the keyboard arrow keys. |
yeah, same with me, but it seems to be not happened in a simple list witch is https://github.com/gizak/termui/blob/master/_examples/list.go |
I'm looking into moving away from termbox-go anyway, since it's not actively maintained anymore. |
That's a good idea, consider using https://github.com/gdamore/tcell |
I don't know if my situation is the same or something else, but nevertheless I will leave my information here I came across this error when I was doing logic with pressing Space or Enter and wanted to do tricky logic with binary flags and using this flag in various places of the program. As a result, it worked, but the Panic occurred as suddenly as possible and not at the time. Later I reduced the logic using flags and the application began to work stably. I think it's a reaction to the termbox.Key* must be strictly immediately after pressing, and if this trigger is worked out later, there is a risk of this error. My fix: Piknik1990/countdowndsm@9d558e1 |
Not sure about other cases, but @Piknik1990's case might be the race condition. I see you run multiple goroutines here: https://github.com/Piknik1990/countdowndsm/blob/9d558e149463fbf3c14f8e99056ac3931ac07bc5/main.go#L108-L136 and all do "termbox.PollEvent()". Termbox is not really a thread safe library. You can in theory use event polling and drawing code in separate threads. But it doesn't mean you can poll events from multiple threads. I'd guess other panics like that might be of similar origin. Worth trying the race detector (although it might be tricky to use it with a terminal ui program, figure out how to redirect its output, etc). |
panic: runtime error: slice bounds out of range --------------------+
goroutine 15 [running]:
github.com/nsf/termbox-go.PollEvent(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
/home/widon/golang/src/github.com/nsf/termbox-go/api.go:330 +0x7ca
golang2048_game/g2048.(*G2048).mrgeAndReturnKey.func1(0xc42001c4e0)
/home/widon/golang/src/golang2048_game/g2048/2048.go:252 +0x34
created by golang2048_game/g2048.(*G2048).mrgeAndReturnKey
/home/widon/golang/src/golang2048_game/g2048/2048.go:254 +0x91
api.go: 330 copy(inbuf, inbuf[event.N:])
I print the len(inbuf) and event.N is 0, 3
The text was updated successfully, but these errors were encountered: