teeworlds-go / protocol

Teeworlds 0.7 network protocol library
BSD 2-Clause "Simplified" License
2 stars 1 forks source link

occasionally getting index out of range panics #26

Open jxsl13 opened 2 months ago

jxsl13 commented 2 months ago
2024/09/19 02:35:14 INFO disconnected from server: 115.28.130.146:8298 ip=115.28.130.146 port=8298
panic: runtime error: index out of range [241] with length 241

goroutine 34 [running]:
github.com/teeworlds-go/protocol/packer.(*Unpacker).byte(0x140001dac20)
    /Users/john/Desktop/protocol/packer/packer.go:21 +0x60
github.com/teeworlds-go/protocol/packer.(*Unpacker).GetInt(0x140001dac20)
    /Users/john/Desktop/protocol/packer/packer.go:142 +0x24
github.com/teeworlds-go/protocol/snapshot7.UnpackDelta(0x140000b71d0, 0x140001dac20)
    /Users/john/Desktop/protocol/snapshot7/snapshot7.go:159 +0x2cc
github.com/teeworlds-go/protocol/teeworlds7.(*Client).processSystem.func6()
    /Users/john/Desktop/protocol/teeworlds7/system.go:101 +0x7bc
github.com/teeworlds-go/protocol/teeworlds7.userMsgCallback[...]({0x0, 0x0, 0x0}, 0x1400009e140, 0x140001dac00)
    /Users/john/Desktop/protocol/teeworlds7/callbacks.go:27 +0x60
github.com/teeworlds-go/protocol/teeworlds7.(*Client).processSystem(0x14000351008, {0x102fa6330, 0x1400009e140}, 0x1400011e4c0)
    /Users/john/Desktop/protocol/teeworlds7/system.go:67 +0xd6c
github.com/teeworlds-go/protocol/teeworlds7.(*Client).processMessage(0x14000351008, {0x102fa6330, 0x1400009e140}, 0x1400011e4c0)
    /Users/john/Desktop/protocol/teeworlds7/packet.go:47 +0xd8
github.com/teeworlds-go/protocol/teeworlds7.(*Client).processPacket(0x14000351008, 0x1400011e480)
    /Users/john/Desktop/protocol/teeworlds7/packet.go:136 +0xce4
github.com/teeworlds-go/protocol/teeworlds7.(*Client).ConnectContext(0x14000351008, {0x102fa4ac8, 0x14000322370}, {0x1400044968d, 0xe}, 0x206a)
    /Users/john/Desktop/protocol/teeworlds7/networking.go:147 +0xf30
github.com/teeworlds-go/protocol/examples/client_trivia/bot.(*Bot).start(0x14000198000, {0x102fa4ac8, 0x14000322370}, {0x1400044968d, 0xe}, 0x206a)
    /Users/john/Desktop/protocol/examples/client_trivia/bot/bot.go:115 +0x5a0
github.com/teeworlds-go/protocol/examples/client_trivia/bot.(*Bot).Run.func1()
    /Users/john/Desktop/protocol/examples/client_trivia/bot/bot.go:57 +0x3c0
github.com/teeworlds-go/protocol/examples/client_trivia/bot.(*Bot).retry(0x14000198000, {0x102fa4c88, 0x140000c4240}, 0x14000319df0)
    /Users/john/Desktop/protocol/examples/client_trivia/bot/bot.go:159 +0x44
github.com/teeworlds-go/protocol/examples/client_trivia/bot.(*Bot).Run(0x14000198000, {0x102fa4c88, 0x140000c4240})
    /Users/john/Desktop/protocol/examples/client_trivia/bot/bot.go:40 +0x13c
main.main.func1(0x0)
    /Users/john/Desktop/protocol/examples/client_trivia/main.go:33 +0xc4
created by main.main in goroutine 1
    /Users/john/Desktop/protocol/examples/client_trivia/main.go:31 +0x2e4
jxsl13 commented 2 months ago

crank up the concurrent connections in trivia example (main.go) to 5-100, start the app, wait until all of them connected, send a SIGINT to application for graceful shutdown, I guess. Or join ingame and tell some trivia client to leave. Those are like the instances where I faced these crashes.

We might want to change client name of the trivia client in order to more easily find them ingame.

Might be related to getting incomplete data upon shutdown from network that wants to be processed, just a guess...