Skip to content

panic due to UnaryServerInterceptor StartTransaction call with nil metadata #37

@mweibel

Description

@mweibel

Hi,

thanks for this library.

I upgraded to the non-released version (go modules, need to figure out why this happened exactly) and noticed a panic with one of the last commits.

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x1016202ac]

goroutine 86 [running]:
github.com/getsentry/sentry-go.StartSpan({0x10208a7c0, 0x14000314a20}, {0x0, 0x0}, {0x14000340580, 0x5, 0x8})
	/path/to/go/pkg/mod/github.com/getsentry/[email protected]/tracing.go:186 +0x40c
github.com/getsentry/sentry-go.StartTransaction({0x10208a7c0, 0x14000314a20}, {0x101a14992, 0x28}, {0x14000340580, 0x5, 0x8})
	/path/to/go/pkg/mod/github.com/getsentry/[email protected]/tracing.go:1003 +0x1cc
github.com/johnbellone/grpc-middleware-sentry.UnaryServerInterceptor.func1({0x10208a7c0, 0x14000314a20}, {0x102025ce0, 0x14000116540}, 0x1400031a520, 0x14000340540)
	/path/to/go/pkg/mod/github.com/johnbellone/[email protected]/server_interceptors.go:54 +0x298
google.golang.org/grpc.getChainUnaryHandler.func1({0x10208a7c0, 0x14000314840}, {0x102025ce0, 0x14000116540})
	/path/to/go/pkg/mod/google.golang.org/[email protected]/server.go:1217 +0xd0
github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors.UnaryServerInterceptor.func1({0x10208a7c0, 0x14000314840}, {0x102025ce0, 0x14000116540}, 0x1400031a520, 0x14000340300)
	/path/to/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware/[email protected]/interceptors/server.go:22 +0x27c
google.golang.org/grpc.chainUnaryInterceptors.func1({0x10208a7c0, 0x14000314840}, {0x102025ce0, 0x14000116540}, 0x1400031a520, 0x1400033e0a8)
	/path/to/go/pkg/mod/google.golang.org/[email protected]/server.go:1208 +0xb4
myHandler({0x101f97440, 0x1400039f040}, {0x10208a7c0, 0x14000314840}, 0x140000fa100, 0x140002e7200)
	/path/to/helio/core/services/inventory/inventory_v1/inventory_grpc.pb.go:104 +0x1e4
google.golang.org/grpc.(*Server).processUnaryRPC(0x140001f5600, {0x10208a7c0, 0x14000314720}, 0x140001163c0, 0x140003e2690, 0x1026cb880, 0x0)
	/path/to/go/pkg/mod/google.golang.org/[email protected]/server.go:1405 +0x14bc
google.golang.org/grpc.(*Server).handleStream(0x140001f5600, {0x10208aca8, 0x140002be1a0}, 0x140001163c0)
	/path/to/go/pkg/mod/google.golang.org/[email protected]/server.go:1815 +0xa04
google.golang.org/grpc.(*Server).serveStreams.func2.1()
	/path/to/go/pkg/mod/google.golang.org/[email protected]/server.go:1035 +0x144
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 85
	/path/to/go/pkg/mod/google.golang.org/[email protected]/server.go:1046 +0x1c8

Change seems to be because of this:
3a613ca#diff-42afeb17cf4f545e63c2c976edf031bd183d39c75ad79fe9729f25a361c25b93R164-R169

Before, ContinueFromGrpcMetadata returned a SpanOption even if there was no span. Now it returns nil and StartTransaction -> StartSpan can't handle with a nil option. Instead of reverting, I assume a better fix would be to call StartTransaction only with non-nil options.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions