markus-wa / demoinfocs-golang

A Counter-Strike 2 & CS:GO demo parser for Go (demoinfo)
https://pkg.go.dev/github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs?tab=doc
MIT License
712 stars 95 forks source link

runtime error: index out of range [1] with length 1 #566

Open mavrick opened 1 month ago

mavrick commented 1 month ago

Describe the bug

Starting!
{received GameEvent but event descriptors are missing 3}

Player hurt event without weapon occurred

Player hurt event without weapon occurred

{unknown event "cs_game_disconnected" 0}

{unknown event "grenade_bounce" 0}

{unknown event "warmup_end" 0}

runtime error: index out of range [1] with length 1
stacktrace:
goroutine 6 [running]:
runtime/debug.Stack()
        runtime/debug/stack.go:24 +0x5e
github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs.NewParserWithConfig.func1({0x13f4300?, 0xc001a40d40})
        github.com/markus-wa/demoinfocs-golang/v4@v4.2.6/pkg/demoinfocs/parser.go:403 +0x2f
github.com/markus-wa/godispatch.(*Dispatcher).dispatchWithRecover.func1()
        github.com/markus-wa/godispatch@v1.4.1/dispatch.go:197 +0x3b
panic({0x13f4300?, 0xc001a40d40?})
        runtime/panic.go:914 +0x21f
github.com/markus-wa/godispatch.callConsumerCode.func1()
        github.com/markus-wa/godispatch@v1.4.1/dispatch.go:122 +0x54
panic({0x1452ce0?, 0xc001b10930?})
        runtime/panic.go:914 +0x21f
github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs.mapGameEventData(...)
        github.com/markus-wa/demoinfocs-golang/v4@v4.2.6/pkg/demoinfocs/game_events.go:1117
github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs.(*parser).handleGameEvent(0xc0002ccc40, 0xc00181b6b8)
        github.com/markus-wa/demoinfocs-golang/v4@v4.2.6/pkg/demoinfocs/game_events.go:65 +0x379
github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs.(*parser).handleGameEventS2(0xc0002ccc40, 0xc001573c20)
        github.com/markus-wa/demoinfocs-golang/v4@v4.2.6/pkg/demoinfocs/game_events.go:118 +0x385
reflect.Value.call({0x1389da0?, 0xc000054eb0?, 0xc0002dbb90?}, {0x14b4fc0, 0x4}, {0xc00181bef8, 0x1, 0x3?})   
        reflect/value.go:596 +0xce7
reflect.Value.Call({0x1389da0?, 0xc000054eb0?, 0x0?}, {0xc00181bef8?, 0x2900000000000000?, 0x3?})
        reflect/value.go:380 +0xb9
github.com/markus-wa/godispatch.callConsumerCode({0x1389da0?, 0xc000054eb0?, 0xc000058500?}, {0xc00181bef8?, 0xfe7306?, 0x0?})
        github.com/markus-wa/godispatch@v1.4.1/dispatch.go:125 +0x3f
github.com/markus-wa/godispatch.(*Dispatcher).Dispatch(0xc0000a8600, {0x14558e0, 0xc001573c20})
        github.com/markus-wa/godispatch@v1.4.1/dispatch.go:111 +0x1d4
github.com/markus-wa/godispatch.(*Dispatcher).dispatchWithRecover(0xc0000a8618?, {0x14558e0?, 0xc001573c20?}) 
        github.com/markus-wa/godispatch@v1.4.1/dispatch.go:202 +0x4f
github.com/markus-wa/godispatch.(*Dispatcher).dispatchQueue(0xc0000a8600, 0x0?)
        github.com/markus-wa/godispatch@v1.4.1/dispatch.go:177 +0xd0
created by github.com/markus-wa/godispatch.(*Dispatcher).AddQueues in goroutine 1
        github.com/markus-wa/godispatch@v1.4.1/dispatch.go:162 +0x18a

To Reproduce parse demo: https://drive.google.com/file/d/13-jHqduYjMKKwudaheLJwXg-SjTj3FK0/view?usp=sharing

Library version v4.3.0

Additional context using node module: @akiver/cs-demo-analyzer

akiver commented 1 month ago

Since this demo doesn't contain the game event list message it uses the list embedded with the lib. The game event list schema changed since the network protocol v14023 so recent demos may not work.

Not sure how you want to deal with this problem @markus-wa ? Here is how I handle upgrades in my analyzer - if we update the bin file it will break older older demos compatibility.

markus-wa commented 1 month ago

Can we tell the network protocol from a demo? if so we should have a map of version->game event list.

akiver commented 1 month ago

Can we tell the network protocol from a demo? if so we should have a map of version->game event list.

This information is inside the first proto message of a demo (CDemoFileHeader), I think we could update source2FallbackGameEventListBin when we got the message

markus-wa commented 1 month ago

sounds good to me :+1: :smile: