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

sentrygin panic on SetSDKIdentifier when no client available #714

Closed
DavidS-ovm opened this issue Sep 13, 2023 · 2 comments · Fixed by #715
Closed

sentrygin panic on SetSDKIdentifier when no client available #714

DavidS-ovm opened this issue Sep 13, 2023 · 2 comments · Fixed by #715
Assignees

Comments

@DavidS-ovm
Copy link

Summary

In https://github.com/getsentry/sentry-go/pull/694/files#diff-f8ff9a2da9d4e109b68c34dc392423f49627462a559a95e25bd907311fde8adaR61 hub.Client() can return nil, crashing moments later in SetSDKIdentifier().

Steps To Reproduce

On my local machine, I have sentrygin injected with engin.Use(sentrygin.New(sentrygin.Options{Repanic: true})) but no other setup. When accessing endpoints, the sentrygin middleware panics:

2023/09/13 11:45:35 [Recovery] 2023/09/13 - 11:45:35 panic recovered:
runtime error: invalid memory address or nil pointer dereference
/usr/local/go/src/runtime/panic.go:261 (0x451f37)
        panicmem: panic(memoryError)
/usr/local/go/src/runtime/signal_unix.go:861 (0x451f05)
        sigpanic: panicmem()
/go/pkg/mod/github.com/getsentry/sentry-go@v0.24.0/client.go:573 (0x92ffcd)
        (*Client).SetSDKIdentifier: client.mu.Lock()
/go/pkg/mod/github.com/getsentry/sentry-go@v0.24.0/gin/sentrygin.go:61 (0x1aacd5c)
        (*handler).handle: hub.Client().SetSDKIdentifier(sdkIdentifier)
/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 (0x1aa28fd)
        (*Context).Next: c.handlers[c.index](c)
/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/logger.go:240 (0x1aa28cc)
        LoggerWithConfig.func1: c.Next()
/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 (0x1aa3759)
        (*Context).Next: c.handlers[c.index](c)
/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/recovery.go:102 (0x1aa3747)
        CustomRecoveryWithWriter.func1: c.Next()
/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 (0x1ab1b71)
        (*Context).Next: c.handlers[c.index](c)
/go/pkg/mod/go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin@v0.42.0/gintrace.go:95 (0x1ab1b5a)
        Middleware.func1: c.Next()
/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 (0x1aa19ba)
        (*Context).Next: c.handlers[c.index](c)
/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/gin.go:620 (0x1aa164d)
        (*Engine).handleHTTPRequest: c.Next()
/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/gin.go:576 (0x1aa117c)
        (*Engine).ServeHTTP: engine.handleHTTPRequest(c)
/usr/local/go/src/net/http/server.go:2514 (0x805221)
        (*ServeMux).ServeHTTP: h.ServeHTTP(w, r)
/go/pkg/mod/github.com/rs/cors@v1.10.0/cors.go:279 (0x1ad81e3)
        (*Server).Init.(*Cors).Handler.func74: h.ServeHTTP(w, r)
/usr/local/go/src/net/http/server.go:2136 (0x803908)
        HandlerFunc.ServeHTTP: f(w, r)
/usr/local/go/src/net/http/server.go:2938 (0x8065ed)
        serverHandler.ServeHTTP: handler.ServeHTTP(rw, req)
/usr/local/go/src/net/http/server.go:2009 (0x8024d3)
        (*conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req)
/usr/local/go/src/runtime/asm_amd64.s:1650 (0x46ebc0)
        goexit: BYTE    $0x90   // NOP

Environment

SDK

  • sentry-go version: v0.24.0
  • Go version: 1.21
  • Using Go Modules? yes
@cleptric cleptric self-assigned this Sep 13, 2023
@cleptric
Copy link
Member

Thanks for the report, we'll get this fixed!

@cleptric
Copy link
Member

We released v0.24.1 which fixes the issue.

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

Successfully merging a pull request may close this issue.

2 participants