Skip to content
This repository has been archived by the owner on Nov 16, 2019. It is now read-only.

Panic: Index Out of Range calling GetPlayerMap() #25

Closed
sb89 opened this issue Sep 3, 2016 · 4 comments
Closed

Panic: Index Out of Range calling GetPlayerMap() #25

sb89 opened this issue Sep 3, 2016 · 4 comments

Comments

@sb89
Copy link

sb89 commented Sep 3, 2016

I received the following error when calling GetPlayerMap():

panic: runtime error: index out of range

goroutine 59 [running]:
panic(0x757360, 0xc420010130)
/usr/lib/go/src/runtime/panic.go:500 +0x1a1
github.com/pogodevorg/pgoapi-go/api.(_Session).Announce(0xc42017c0a0, 0x987960, 0xc420010578, 0x7a6060, 0x474a01, 0xc4204eee40)
/home/steven/programming/go/src/github.com/pogodevorg/pgoapi-go/api/session.go:276 +0x800
github.com/pogodevorg/pgoapi-go/api.(_Session).GetPlayerMap(0xc42017c0a0, 0x987960, 0xc420010578, 0xc4203c9cd0, 0x2, 0x2)
/home/steven/programming/go/src/github.com/pogodevorg/pgoapi-go/api/session.go:307 +0x3f
mogo-go/process.(_Worker).Run.func1()
/home/steven/programming/go/src/mogo-go/process/worker.go:54 +0x150
mogo-go/process.(_Worker).Run.func1()
/home/steven/programming/go/src/mogo-go/process/worker.go:77 +0x3b2
created by mogo-go/process.(*Worker).Run
/home/steven/programming/go/src/mogo-go/process/worker.go:80 +0xca
exit status 2

It seems to come from err = proto.Unmarshal(response.Returns[5], mapObjects) in session.go. I'm not sure why it occurred but it only happened once after a couple of hours of testing. Perhaps we should check if the slice contains the required amount of elements before trying to access it?

@sb89
Copy link
Author

sb89 commented Sep 3, 2016

It happened again. I believe it's probably because my session timed out, hence when it tries to scan it returns nothing.

@zeevallin
Copy link
Contributor

@sb89 I think it might be wise to iterate the responses, return with no error if it reaches 5. Push the others to the feed.

@femot
Copy link
Contributor

femot commented Sep 8, 2016

This is the same as #16

@femot
Copy link
Contributor

femot commented Nov 11, 2016

fixed in ec8a3f2

@femot femot closed this as completed Nov 11, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

3 participants