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

interface {} is nil, not int32 panic when calling AmmoReserve on POV demo #570

Closed
hjbdev opened this issue Nov 25, 2024 · 2 comments
Closed

Comments

@hjbdev
Copy link

hjbdev commented Nov 25, 2024

Describe the bug
Calling the AmmoReserve method panics during this particular demo.

Stack trace:

panic: interface conversion: interface {} is nil, not int32
        stacktrace:
        goroutine 7 [running]:
        runtime/debug.Stack()
                C:/Program Files/Go/src/runtime/debug/stack.go:26 +0x5e
        github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs.NewParserWithConfig.func1({0x452620, 0xc0005dcce0})
                C:/Users/Harry/go/pkg/mod/github.com/markus-wa/demoinfocs-golang/[email protected]/pkg/demoinfocs/parser.go:404 +0x2a
        github.com/markus-wa/godispatch.(*Dispatcher).dispatchWithRecover.func1()
                C:/Users/Harry/go/pkg/mod/github.com/markus-wa/[email protected]/dispatch.go:197 +0x3b
        panic({0x452620?, 0xc0005dcce0?})
                C:/Program Files/Go/src/runtime/panic.go:785 +0x132
        github.com/markus-wa/godispatch.callConsumerCode.func1()
                C:/Users/Harry/go/pkg/mod/github.com/markus-wa/[email protected]/dispatch.go:122 +0x4d
        panic({0x452620?, 0xc0005dccd0?})
                C:/Program Files/Go/src/runtime/panic.go:785 +0x132
        github.com/markus-wa/godispatch.callConsumerCode.func1()
                C:/Users/Harry/go/pkg/mod/github.com/markus-wa/[email protected]/dispatch.go:122 +0x4d
        panic({0x427ac0?, 0xc0012ac000?})
                C:/Program Files/Go/src/runtime/panic.go:785 +0x132
        github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs/sendtables.PropertyValue.Int(...)
                C:/Users/Harry/go/pkg/mod/github.com/markus-wa/demoinfocs-golang/[email protected]/pkg/demoinfocs/sendtables/propdecoder.go:137
        github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs/common.(*Equipment).AmmoReserve(0xc000db0140)
                C:/Users/Harry/go/pkg/mod/github.com/markus-wa/demoinfocs-golang/[email protected]/pkg/demoinfocs/common/equipment.go:421 +0x20e
        main.main.func1({})
                C:/Users/Harry/Dev/stratbox/lib/2d-replay-generator/bugrepro.go:24 +0xdf
        reflect.Value.call({0x3ef7e0?, 0xc000008660?, 0xc00369d760?}, {0x5157f7, 0x4}, {0xc004f5f780, 0x1, 0x0?})
                C:/Program Files/Go/src/reflect/value.go:581 +0xca6
        reflect.Value.Call({0x3ef7e0?, 0xc000008660?, 0xbe9a2?}, {0xc004f5f780?, 0x0?, 0x9a00000000000001?})
                C:/Program Files/Go/src/reflect/value.go:365 +0xb9
        github.com/markus-wa/godispatch.callConsumerCode({0x3ef7e0?, 0xc000008660?, 0xc004f5f798?}, {0xc004f5f780?, 0x0?, 0xc004f5f778?})
                C:/Users/Harry/go/pkg/mod/github.com/markus-wa/[email protected]/dispatch.go:125 +0x3f
        github.com/markus-wa/godispatch.(*Dispatcher).Dispatch(0xc000098180, {0x41cf00, 0x91e2c0})
                C:/Users/Harry/go/pkg/mod/github.com/markus-wa/[email protected]/dispatch.go:111 +0x1f5
        github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs.(*parser).handleFrameParsed(0xc00007b6c0, 0x0?)
                C:/Users/Harry/go/pkg/mod/github.com/markus-wa/demoinfocs-golang/[email protected]/pkg/demoinfocs/parsing.go:539 +0x38
        reflect.Value.call({0x3f03e0?, 0xc000042d60?, 0x0?}, {0x5157f7, 0x4}, {0xc004f5fef0, 0x1, 0xe0585?})
                C:/Program Files/Go/src/reflect/value.go:581 +0xca6
        reflect.Value.Call({0x3f03e0?, 0xc000042d60?, 0xbe9a2?}, {0xc004f5fef0?, 0x1ddc89092ae2c?, 0xd90000c00007b880?})
                C:/Program Files/Go/src/reflect/value.go:365 +0xb9
        github.com/markus-wa/godispatch.callConsumerCode({0x3f03e0?, 0xc000042d60?, 0xc004f5ff08?}, {0xc004f5fef0?, 0xc004f5fec0?, 0xc0003ced00?})
                C:/Users/Harry/go/pkg/mod/github.com/markus-wa/[email protected]/dispatch.go:125 +0x3f
        github.com/markus-wa/godispatch.(*Dispatcher).Dispatch(0xc000098120, {0x3daea0, 0x91e2c0})
                C:/Users/Harry/go/pkg/mod/github.com/markus-wa/[email protected]/dispatch.go:111 +0x1f5
        github.com/markus-wa/godispatch.(*Dispatcher).dispatchWithRecover(0xc000098120?, {0x3daea0?, 0x91e2c0?})
                C:/Users/Harry/go/pkg/mod/github.com/markus-wa/[email protected]/dispatch.go:202 +0x49
        github.com/markus-wa/godispatch.(*Dispatcher).dispatchQueue(0xc000098120, 0xc0000c72d0)
                C:/Users/Harry/go/pkg/mod/github.com/markus-wa/[email protected]/dispatch.go:177 +0xd0
        created by github.com/markus-wa/godispatch.(*Dispatcher).AddQueues in goroutine 1
                C:/Users/Harry/go/pkg/mod/github.com/markus-wa/[email protected]/dispatch.go:162 +0x17f


goroutine 1 [running]:
main.checkError(...)
        C:/Users/Harry/Dev/stratbox/lib/2d-replay-generator/bugrepro.go:39
main.main()
        C:/Users/Harry/Dev/stratbox/lib/2d-replay-generator/bugrepro.go:34 +0x185
exit status 2

To Reproduce
https://wompwomp.ams3.digitaloceanspaces.com/harry.dem

Code:

package main

import (
	"fmt"
	"os"

	ex "github.com/markus-wa/demoinfocs-golang/v4/examples"
	demoinfocs "github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs"
	events "github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs/events"
)

func main() {
	f, err := os.Open(ex.DemoPathFromArgs())
	checkError(err)
	defer f.Close()

	p := demoinfocs.NewParser(f)
	defer p.Close()

	p.RegisterEventHandler(func(e events.FrameDone) {
		gs := p.GameState()
		for _, p := range gs.Participants().Playing() {
			for _, equipment := range p.Inventory {
				reserveAmmo := equipment.AmmoReserve()

				// hacky way to call the getter but not spam the console. Ignore this bit.
				if reserveAmmo == 200 {
					fmt.Println("equipment", equipment.String(), "ammo in reserve", equipment.AmmoReserve())
				}
			}
		}
	})

	err = p.ParseToEnd()
	checkError(err)
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}

Expected behavior
No panic

Library version
v4.3.0, also tried master up to 5125a5a9c0252028c17ddab9d2922797ec6bc272

Additional context
Windows 11

@markus-wa
Copy link
Owner

fixed in v4.3.1 :)

@hjbdev
Copy link
Author

hjbdev commented Jan 24, 2025

thank you 🐐!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants