spicedb: v1.34.0 Segfault on ReadRelationships before WriteSchema when using memstore

What platforms are affected?

macos

What architectures are affected?

amd64

What SpiceDB version are you using?

v1.34.0

Steps to Reproduce

Docker image sha256:5f81b3ea0702907c847e11cb20a6a58d60921811628da6776336ce2da7c60d68.

I can provide a Docker image and code if you send me an Image registry I can push to. I stopped a SpiceDB Docker container, and then restarted it with docker start -a <container-id> and attempted to ReadRelationships for some non-existent schema. The FailedPrecondition seems to be the cause of the segfault.

Expected Result

Spice should not segfault. ReadRelationships should return an error.

Actual Result

Segmentation Fault. Logs:

{"level":"warn","protocol":"grpc","grpc.component":"server","grpc.service":"authzed.api.v1.PermissionsService","grpc.method":"ReadRelationships","grpc.method_type":"server_stream","requestID":"edd969d0685a5dda472a2c43b57d41d0","peer.address":"192.168.65.1:60543","grpc.start_time":"2024-07-17T13:27:29Z","grpc.code":"FailedPrecondition","grpc.error":"object definition `team` not found","grpc.time_ms":0,"time":"2024-07-17T13:27:29Z","message":"finished call"}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0xe55780]

goroutine 360 [running]:
github.com/authzed/spicedb/internal/namespace.CheckNamespaceAndRelations({0x2db1268, 0x4000bec1b0}, {0x4000e7e238, 0x2, 0x40008bf1d0?}, {0x2dbdaa0, 0x4000bec240})
	/home/runner/actions-runner/_work/spicedb/spicedb/internal/namespace/util.go:72 +0x2c0
github.com/authzed/spicedb/internal/services/v1.(*permissionServer).CheckPermission(0x40008ca870, {0x2db1268, 0x4000bec1b0}, 0x4000c7d260)
	/home/runner/actions-runner/_work/spicedb/spicedb/internal/services/v1/permissions.go:53 +0x154
github.com/authzed/authzed-go/proto/authzed/api/v1._PermissionsService_CheckPermission_Handler.func1({0x2db1268, 0x4000bec1b0}, {0x25cd1c0?, 0x4000c7d260})
	/home/runner/go/pkg/mod/github.com/authzed/authzed-go@v0.10.1/proto/authzed/api/v1/permission_service_grpc.pb.go:342 +0x74
github.com/authzed/spicedb/internal/services/v1.NewPermissionsServer.UnaryServerInterceptor.UnaryServerInterceptor.func4({0x2db1268, 0x4000bec0c0}, {0x25cd1c0, 0x4000c7d260}, 0x4000e7e601?, 0x4000c9a8e8)
	/home/runner/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware/v2@v2.0.1/interceptors/server.go:22 +0x1f0
github.com/authzed/spicedb/internal/services/v1.NewPermissionsServer.ChainUnaryServer.func1.1.1({0x2db1268?, 0x4000bec0c0?}, {0x25cd1c0?, 0x4000c7d260?})
	/home/runner/actions-runner/_work/spicedb/spicedb/internal/middleware/chain.go:23 +0x40
github.com/authzed/spicedb/internal/middleware/handwrittenvalidation.UnaryServerInterceptor({0x2db1268, 0x4000bec0c0}, {0x25cd1c0, 0x4000c7d260}, 0xffff5aa3fca8?, 0x4000754dc0)
	/home/runner/actions-runner/_work/spicedb/spicedb/internal/middleware/handwrittenvalidation/handwrittenvalidation.go:26 +0xc0
github.com/authzed/spicedb/internal/services/v1.NewPermissionsServer.ChainUnaryServer.func1.1.1({0x2db1268?, 0x4000bec0c0?}, {0x25cd1c0?, 0x4000c7d260?})
	/home/runner/actions-runner/_work/spicedb/spicedb/internal/middleware/chain.go:23 +0x40
github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/validator.UnaryServerInterceptor.func1({0x2db1268, 0x4000bec0c0}, {0x25cd1c0, 0x4000c7d260}, 0x30?, 0x4000754e00)
	/home/runner/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware/v2@v2.0.1/interceptors/validator/interceptors.go:23 +0x7c
github.com/authzed/spicedb/internal/services/v1.NewPermissionsServer.ChainUnaryServer.func1.1.1({0x2db1268?, 0x4000bec0c0?}, {0x25cd1c0?, 0x4000c7d260?})
	/home/runner/actions-runner/_work/spicedb/spicedb/internal/middleware/chain.go:23 +0x40
github.com/authzed/spicedb/internal/services/v1.NewPermissionsServer.ChainUnaryServer.func1({0x2db1268, 0x4000bec0c0}, {0x25cd1c0, 0x4000c7d260}, 0x4000e7e7f8?, 0x12c3528?)
	/home/runner/actions-runner/_work/spicedb/spicedb/internal/middleware/chain.go:32 +0xb8
github.com/authzed/spicedb/internal/middleware/servicespecific.UnaryServerInterceptor({0x2db1268, 0x4000bec0c0}, {0x25cd1c0, 0x4000c7d260}, 0x4000754c20, 0x4000c9a8e8)
	/home/runner/actions-runner/_work/spicedb/spicedb/internal/middleware/servicespecific/servicespecific.go:25 +0x84
google.golang.org/grpc.getChainUnaryHandler.func1({0x2db1268, 0x4000bec0c0}, {0x25cd1c0, 0x4000c7d260})
	/home/runner/go/pkg/mod/google.golang.org/grpc@v1.61.0/server.go:1205 +0xa0
github.com/authzed/spicedb/pkg/cmd/server.DefaultUnaryMiddleware.UnaryServerInterceptor.func15({0x2db1268, 0x4000bec090}, {0x25cd1c0, 0x4000c7d260}, 0x4000754c20, 0x4000b518c0)
	/home/runner/actions-runner/_work/spicedb/spicedb/internal/middleware/consistency/consistency.go:191 +0x138
google.golang.org/grpc.getChainUnaryHandler.func1({0x2db1268, 0x4000bec090}, {0x25cd1c0, 0x4000c7d260})
	/home/runner/go/pkg/mod/google.golang.org/grpc@v1.61.0/server.go:1205 +0xa0
github.com/authzed/spicedb/pkg/cmd/server.DefaultUnaryMiddleware.UnaryServerInterceptor.func13({0x2db1268?, 0x4000bec060?}, {0x25cd1c0, 0x4000c7d260}, 0x4000754c20?, 0x4000b51880)
	/home/runner/actions-runner/_work/spicedb/spicedb/internal/middleware/datastore/datastore.go:70 +0x90
google.golang.org/grpc.getChainUnaryHandler.func1({0x2db1268, 0x4000bec060}, {0x25cd1c0, 0x4000c7d260})
	/home/runner/go/pkg/mod/google.golang.org/grpc@v1.61.0/server.go:1205 +0xa0
github.com/authzed/spicedb/pkg/cmd/server.DefaultUnaryMiddleware.UnaryServerInterceptor.func11({0x2db1268?, 0x4000969fb0?}, {0x25cd1c0, 0x4000c7d260}, 0x4000754c20?, 0x4000b51840)
	/home/runner/actions-runner/_work/spicedb/spicedb/internal/middleware/dispatcher/dispatcher.go:66 +0x90
google.golang.org/grpc.getChainUnaryHandler.func1({0x2db1268, 0x4000969fb0}, {0x25cd1c0, 0x4000c7d260})
	/home/runner/go/pkg/mod/google.golang.org/grpc@v1.61.0/server.go:1205 +0xa0
github.com/authzed/spicedb/pkg/cmd/server.DefaultUnaryMiddleware.UnaryServerInterceptor.UnaryServerInterceptor.func20({0x2db1268, 0x4000969fb0}, {0x25cd1c0, 0x4000c7d260}, 0x4000754c20?, 0x4000b51800)
	/home/runner/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware/v2@v2.0.1/interceptors/server.go:22 +0x1f0
google.golang.org/grpc.getChainUnaryHandler.func1({0x2db1268, 0x4000969fb0}, {0x25cd1c0, 0x4000c7d260})
	/home/runner/go/pkg/mod/google.golang.org/grpc@v1.61.0/server.go:1205 +0xa0
github.com/authzed/spicedb/pkg/cmd/server.DefaultUnaryMiddleware.UnaryServerInterceptor.func8({0x2db1268, 0x4000969fb0}, {0x25cd1c0, 0x4000c7d260}, 0x4000754c20, 0x4000b517c0)
	/home/runner/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware/v2@v2.0.1/interceptors/auth/auth.go:48 +0xbc
google.golang.org/grpc.getChainUnaryHandler.func1({0x2db1268, 0x4000969fb0}, {0x25cd1c0, 0x4000c7d260})
	/home/runner/go/pkg/mod/google.golang.org/grpc@v1.61.0/server.go:1205 +0xa0
github.com/grpc-ecosystem/go-grpc-prometheus.init.(*ServerMetrics).UnaryServerInterceptor.func3({0x2db1268, 0x4000969fb0}, {0x25cd1c0, 0x4000c7d260}, 0x4000754c20?, 0x4000b51780)
	/home/runner/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-prometheus@v1.2.0/server_metrics.go:107 +0x74
google.golang.org/grpc.getChainUnaryHandler.func1({0x2db1268, 0x4000969fb0}, {0x25cd1c0, 0x4000c7d260})
	/home/runner/go/pkg/mod/google.golang.org/grpc@v1.61.0/server.go:1205 +0xa0
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc.UnaryServerInterceptor.func1({0x2db1268, 0x4000969d10}, {0x25cd1c0, 0x4000c7d260}, 0x4000754c20, 0x4000b51700)
	/home/runner/go/pkg/mod/go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc@v0.47.0/interceptor.go:326 +0x3f0
google.golang.org/grpc.getChainUnaryHandler.func1({0x2db1268, 0x4000969d10}, {0x25cd1c0, 0x4000c7d260})
	/home/runner/go/pkg/mod/google.golang.org/grpc@v1.61.0/server.go:1205 +0xa0
github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/logging.UnaryServerInterceptor.UnaryServerInterceptor.func2({0x2db1268, 0x4000969ce0}, {0x25cd1c0, 0x4000c7d260}, 0x4000754c20?, 0x4000b516c0)
	/home/runner/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware/v2@v2.0.1/interceptors/server.go:22 +0x1f0
google.golang.org/grpc.getChainUnaryHandler.func1({0x2db1268, 0x4000969ce0}, {0x25cd1c0, 0x4000c7d260})
	/home/runner/go/pkg/mod/google.golang.org/grpc@v1.61.0/server.go:1205 +0xa0
github.com/authzed/spicedb/pkg/cmd/server.DefaultUnaryMiddleware.UnaryServerInterceptor.UnaryServerInterceptor.func18({0x2db1268, 0x4000969800}, {0x25cd1c0, 0x4000c7d260}, 0x4000754c20?, 0x4000b51680)
	/home/runner/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware/v2@v2.0.1/interceptors/server.go:22 +0x1f0
google.golang.org/grpc.getChainUnaryHandler.func1({0x2db1268, 0x4000969800}, {0x25cd1c0, 0x4000c7d260})
	/home/runner/go/pkg/mod/google.golang.org/grpc@v1.61.0/server.go:1205 +0xa0
github.com/authzed/spicedb/pkg/middleware/requestid.UnaryServerInterceptor.UnaryServerInterceptor.func1({0x2db1268, 0x4000969770}, {0x25cd1c0, 0x4000c7d260}, 0x4000754c20?, 0x4000b51640)
	/home/runner/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware/v2@v2.0.1/interceptors/server.go:22 +0x1f0
google.golang.org/grpc.NewServer.chainUnaryServerInterceptors.chainUnaryInterceptors.func1({0x2db1268, 0x4000969770}, {0x25cd1c0, 0x4000c7d260}, 0x4001303988?, 0x536b98?)
	/home/runner/go/pkg/mod/google.golang.org/grpc@v1.61.0/server.go:1196 +0x88
github.com/authzed/authzed-go/proto/authzed/api/v1._PermissionsService_CheckPermission_Handler({0x24f9e40?, 0x40008ca870}, {0x2db1268, 0x4000969770}, 0x4000b4eb00, 0x4000754940)
	/home/runner/go/pkg/mod/github.com/authzed/authzed-go@v0.10.1/proto/authzed/api/v1/permission_service_grpc.pb.go:344 +0x12c
google.golang.org/grpc.(*Server).processUnaryRPC(0x40005dc800, {0x2db1268, 0x40009696e0}, {0x2dbf358, 0x4001350000}, 0x40012406c0, 0x4000f16f30, 0x47d97d0, 0x0)
	/home/runner/go/pkg/mod/google.golang.org/grpc@v1.61.0/server.go:1385 +0xb8c
google.golang.org/grpc.(*Server).handleStream(0x40005dc800, {0x2dbf358, 0x4001350000}, 0x40012406c0)
	/home/runner/go/pkg/mod/google.golang.org/grpc@v1.61.0/server.go:1796 +0xc4c
google.golang.org/grpc.(*Server).serveStreams.func2.1()
	/home/runner/go/pkg/mod/google.golang.org/grpc@v1.61.0/server.go:1029 +0x8c
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 261
	/home/runner/go/pkg/mod/google.golang.org/grpc@v1.61.0/server.go:1040 +0x150

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17 (8 by maintainers)

Most upvoted comments

@theronic Are you using an in-memory datastore?