Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Bug] panic: runtime error: invalid memory address or nil pointer dereference #30

Open
dmouraneto opened this issue Aug 14, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@dmouraneto
Copy link

Summary

When under high load, sometimes I get this error

goroutine 17 [running]:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x58 pc=0x8e7b68]
/go/pkg/mod/github.com/growthbook/growthbook-golang@v0.1.9/growthbook.go:106 +0x25
github.com/growthbook/growthbook-golang.New.func1(0x0?)
/go/pkg/mod/github.com/growthbook/growthbook-golang@v0.1.9/feature_repository.go:92
github.com/growthbook/growthbook-golang.repoUnsubscribe(...)
/go/pkg/mod/github.com/growthbook/growthbook-golang@v0.1.9/feature_repository.go:432 +0x71
github.com/growthbook/growthbook-golang.(*refreshData).removeSubscription(0x131d3c0, 0xc000f30628)
/go/pkg/mod/github.com/growthbook/growthbook-golang@v0.1.9/feature_repository.go:593
github.com/growthbook/growthbook-golang.getKey(...)
/go/pkg/mod/github.com/growthbook/growthbook-golang@v0.1.9/growthbook.go:519 +0x88
github.com/growthbook/growthbook-golang.(*GrowthBook).GetAPIInfo(0xc000f30628)

Here is the library code where the panic is generated:

func (gb *GrowthBook) GetAPIInfo() (string, string) {
	gb.inner.RLock()
	defer gb.inner.RUnlock()

	apiHost := gb.inner.context.APIHost
	if apiHost == "" {
		apiHost = "https://cdn.growthbook.io"
	}

	return strings.TrimRight(apiHost, "/"), gb.inner.context.ClientKey
}

This code is invoked because of GrowthBook finalizer.
Don't know if the GC can collect the context before running the finalizer code and is causing this issue. Not sure what else can turn the context to an invalid state.

Expected Behavior

Don't panic

Current Behavior

panic

@dmouraneto dmouraneto added the bug Something isn't working label Aug 14, 2024
@abs
Copy link

abs commented Jan 23, 2025

Hi @dmouraneto - any chance you'd be willing to give https://pkg.go.dev/github.com/growthbook/growthbook-golang@v0.2.0 a try to see if it resolves this issue?

@dmouraneto
Copy link
Author

@abs not sure what I did back then but I'm not having the issue anymore.
I'll test this new version and report if I find any issue.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants