Calling GetArchiveRequest RPC with unexptected arguments may lead to runtime error
I am implementing a custom RPC client and stumbled across a bug that I thought might be of interest. Calling the RPC GetArchive
with unexpected arguments can end the Gitaly process with the error message panic: runtime error: invalid memory address or nil pointer dereference
.
I am using Gitaly, version 1.75.0-10-g07c5914b
This is the client code that is sending the RPC:
archclient, err := client.GetArchive(context.Background(), &pb.GetArchiveRequest{
Repository: &pb.Repository{
StorageName: "default",
},
CommitId: "sadf",
Prefix: "qwert",
Format: 1,
Path: []byte("Here is a string...."),
})
Gitaly is logging below messages before the process ends:
{"full_method_name":"/gitaly.RepositoryService/GetArchive","level":"error","msg":"getRepoStatePath: relative path missing from storage_name:\"default\" ","time":"2019-12-13T22:05:56+01:00"}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x16b42fa]
goroutine 494 [running]:
gitlab.com/gitlab-org/gitaly/internal/cache.getRepoStatePath(0x0, 0xc00071ed20, 0xc0005921c0, 0xc000337aa0, 0x14)
/Users/da/git/gitaly/internal/cache/keyer.go:226 +0x3a
gitlab.com/gitlab-org/gitaly/internal/cache.updateLatest(0x0, 0x0, 0x0, 0x0, 0x0)
/Users/da/git/gitaly/internal/cache/keyer.go:79 +0x56
gitlab.com/gitlab-org/gitaly/internal/cache.lease.EndLease(0x0, 0x0, 0x0, 0x1ad71c0, 0xc00071ed20, 0x1ad71c0, 0xc00071ed20)
/Users/da/git/gitaly/internal/cache/keyer.go:63 +0x2f
gitlab.com/gitlab-org/gitaly/internal/middleware/cache.invalidateCache.func1.1(0xc00071edb0, 0x1add780, 0xc00071ede0, 0xc00038b1e0)
/Users/da/git/gitaly/internal/middleware/cache/cache.go:131 +0xa3
gitlab.com/gitlab-org/gitaly/internal/middleware/cache.invalidateCache.func1(0x19978e0, 0xc00043adb0, 0x1add780, 0xc00071ede0, 0x1abd440, 0xc00096e9b0)
/Users/da/git/gitaly/internal/middleware/cache/cache.go:135 +0xf3
gitlab.com/gitlab-org/gitaly/internal/middleware/cache.StreamInvalidator.func1(0x19978e0, 0xc00043adb0, 0x1add4e0, 0xc00038b120, 0xc00038af60, 0xc00038b260, 0xc0007451f0, 0x0)
/Users/da/git/gitaly/internal/middleware/cache/cache.go:59 +0x2b4
github.com/grpc-ecosystem/go-grpc-middleware.ChainStreamServer.func1.1(0x19978e0, 0xc00043adb0, 0x1add4e0, 0xc00038b120, 0xc0003ce0c0, 0x24)
/Users/da/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.0.0/chain.go:74 +0x99
github.com/grpc-ecosystem/go-grpc-middleware/tracing/opentracing.StreamServerInterceptor.func1(0x19978e0, 0xc00043adb0, 0x1add4e0, 0xc00038b120, 0xc00038af60, 0xc00096e5f0, 0x191cd80, 0x1ad7101)
/Users/da/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.0.0/tracing/opentracing/server_interceptors.go:46 +0x144
github.com/grpc-ecosystem/go-grpc-middleware.ChainStreamServer.func1.1(0x19978e0, 0xc00043adb0, 0x1add4e0, 0xc00038b120, 0x0, 0x0)
/Users/da/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.0.0/chain.go:74 +0x99
github.com/grpc-ecosystem/go-grpc-middleware/auth.StreamServerInterceptor.func1(0x19978e0, 0xc00043adb0, 0x1add7e0, 0xc00071ec60, 0xc00038af60, 0xc00096e5f0, 0x19430c0, 0x1)
/Users/da/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.0.0/auth/auth.go:65 +0x148
github.com/grpc-ecosystem/go-grpc-middleware.ChainStreamServer.func1.1(0x19978e0, 0xc00043adb0, 0x1add7e0, 0xc00071ec60, 0x19, 0x19)
/Users/da/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.0.0/chain.go:74 +0x99
gitlab.com/gitlab-org/gitaly/internal/middleware/limithandler.(*LimiterMiddleware).StreamInterceptor.func1(0x19978e0, 0xc00043adb0, 0x1add4e0, 0xc00038b020, 0xc00038af60, 0xc00096e5f0, 0x1060642, 0x104f20c)
/Users/da/git/gitaly/internal/middleware/limithandler/limithandler.go:51 +0x9d
github.com/grpc-ecosystem/go-grpc-middleware.ChainStreamServer.func1.1(0x19978e0, 0xc00043adb0, 0x1add4e0, 0xc00038b020, 0xc0007454a0, 0xc08b60e85f)
/Users/da/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.0.0/chain.go:74 +0x99
gitlab.com/gitlab-org/gitaly/internal/middleware/cancelhandler.Stream(0x19978e0, 0xc00043adb0, 0x1add4e0, 0xc00038b020, 0xc00038af60, 0xc00096e5f0, 0x5df3fd34, 0x3a8f5540)
/Users/da/git/gitaly/internal/middleware/cancelhandler/cancelhandler.go:21 +0x7a
github.com/grpc-ecosystem/go-grpc-middleware.ChainStreamServer.func1.1(0x19978e0, 0xc00043adb0, 0x1add4e0, 0xc00038b020, 0x191cd80, 0x0)
/Users/da/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.0.0/chain.go:74 +0x99
gitlab.com/gitlab-org/gitaly/internal/middleware/sentryhandler.StreamLogHandler(0x19978e0, 0xc00043adb0, 0x1add4e0, 0xc00038b020, 0xc00038af60, 0xc00096e5f0, 0x191cd80, 0x1ad7101)
/Users/da/git/gitaly/internal/middleware/sentryhandler/sentryhandler.go:43 +0x87
github.com/grpc-ecosystem/go-grpc-middleware.ChainStreamServer.func1.1(0x19978e0, 0xc00043adb0, 0x1add4e0, 0xc00038b020, 0x24, 0xbf751d2d3a8ec8a0)
/Users/da/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.0.0/chain.go:74 +0x99
github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus.StreamServerInterceptor.func1(0x19978e0, 0xc00043adb0, 0x1add660, 0xc00038afe0, 0xc00038af60, 0xc00096e5f0, 0x19043c0, 0xc000508e01)
/Users/da/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.0.0/logging/logrus/server_interceptors.go:66 +0x176
github.com/grpc-ecosystem/go-grpc-middleware.ChainStreamServer.func1.1(0x19978e0, 0xc00043adb0, 0x1add660, 0xc00038afe0, 0x24, 0xc00096e690)
/Users/da/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.0.0/chain.go:74 +0x99
github.com/grpc-ecosystem/go-grpc-prometheus.(*ServerMetrics).StreamServerInterceptor.func1(0x19978e0, 0xc00043adb0, 0x1add4e0, 0xc00038afa0, 0xc00038af60, 0xc00096e5f0, 0x7, 0x19a619b)
/Users/da/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-prometheus@v1.2.0/server_metrics.go:121 +0xeb
github.com/grpc-ecosystem/go-grpc-middleware.ChainStreamServer.func1.1(0x19978e0, 0xc00043adb0, 0x1add4e0, 0xc00038afa0, 0x19a619b, 0x7)
/Users/da/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.0.0/chain.go:74 +0x99
gitlab.com/gitlab-org/gitaly/internal/middleware/metadatahandler.StreamInterceptor(0x19978e0, 0xc00043adb0, 0x1add4e0, 0xc00038afa0, 0xc00038af60, 0xc00096e5f0, 0x191cd80, 0xc0004b3501)
/Users/da/git/gitaly/internal/middleware/metadatahandler/metadatahandler.go:121 +0xc2
github.com/grpc-ecosystem/go-grpc-middleware.ChainStreamServer.func1.1(0x19978e0, 0xc00043adb0, 0x1add4e0, 0xc00038afa0, 0xc0004b3580, 0xc00071eb10)
/Users/da/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.0.0/chain.go:74 +0x99
gitlab.com/gitlab-org/labkit/correlation/grpc.StreamServerCorrelationInterceptor.func1(0x19978e0, 0xc00043adb0, 0x1add540, 0xc0004b3580, 0xc00038af60, 0xc00096e5f0, 0x1947320, 0xc0005f8001)
/Users/da/go/pkg/mod/gitlab.com/gitlab-org/labkit@v0.0.0-20190902063225-3253d7975ca7/correlation/grpc/server_interceptors.go:39 +0xbe
github.com/grpc-ecosystem/go-grpc-middleware.ChainStreamServer.func1.1(0x19978e0, 0xc00043adb0, 0x1add540, 0xc0004b3580, 0x18d27a0, 0xc000463b28)
/Users/da/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.0.0/chain.go:74 +0x99
github.com/grpc-ecosystem/go-grpc-middleware/tags.StreamServerInterceptor.func1(0x19978e0, 0xc00043adb0, 0x1add900, 0xc000444000, 0xc00038af60, 0xc00096e5f0, 0xc000463b98, 0x100eb08)
/Users/da/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.0.0/tags/interceptors.go:37 +0x265
github.com/grpc-ecosystem/go-grpc-middleware.ChainStreamServer.func1(0x19978e0, 0xc00043adb0, 0x1add900, 0xc000444000, 0xc00038af60, 0x19e3e30, 0x1ad71c0, 0xc00071eab0)
/Users/da/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.0.0/chain.go:79 +0x14f
google.golang.org/grpc.(*Server).processStreamingRPC(0xc0000a0420, 0x1ae4620, 0xc0004f5e00, 0xc00020c100, 0xc0004b81e0, 0x212bfe0, 0x0, 0x0, 0x0)
/Users/da/go/pkg/mod/google.golang.org/grpc@v1.24.0/server.go:1206 +0x45a
google.golang.org/grpc.(*Server).handleStream(0xc0000a0420, 0x1ae4620, 0xc0004f5e00, 0xc00020c100, 0x0)
/Users/da/go/pkg/mod/google.golang.org/grpc@v1.24.0/server.go:1279 +0xd30
google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc0002fcab0, 0xc0000a0420, 0x1ae4620, 0xc0004f5e00, 0xc00020c100)
/Users/da/go/pkg/mod/google.golang.org/grpc@v1.24.0/server.go:710 +0xbb
created by google.golang.org/grpc.(*Server).serveStreams.func1
/Users/da/go/pkg/mod/google.golang.org/grpc@v1.24.0/server.go:708 +0xa1
Edited by Dennis Appelt