sourcegraph / sourcegraph-public-snapshot

Code AI platform with Code Search & Cody
https://sourcegraph.com
Other
10.11k stars 1.29k forks source link

`src serve-git` exposes `gitservice` package error for `git-upload-pack` endpoint #56706

Closed DaedalusG closed 8 months ago

DaedalusG commented 1 year ago

Steps to reproduce:

Run a local docker-compose deployment on v5.1.8 or earlier. On your local machine set up a src serve-git process serving some local repos.

Example code host config:

{
  // url is the http url to 'src serve-git'.
  // url should be reachable by Sourcegraph.
  "url": "http://host.docker.internal:6969",

  // Do not change this. Sourcegraph uses this as a signal that url is 'src serve'.
  "repos": ["src-serve"]
}

Example src serve-git process

λ ~/test-src-serve/ src -v serve-git -addr :6969
serve-git: 2023/09/15 17:36:23 listening on http://[::]:6969
serve-git: 2023/09/15 17:36:23 serving git repositories from /Users/warrengifford/test-src-serve
DBUG serve-git: 2023/09/15 17:36:37 not a repository root: /Users/warrengifford/test-src-serve
DBUG serve-git: 2023/09/15 17:36:37 git service svc=/info/refs protocol=version=2 repo=flamego/.git duration=8.476644ms
DBUG serve-git: 2023/09/15 17:36:37 git service svc=/info/refs protocol=version=2 repo=gogs/.git duration=8.464262ms

With the following configuration set you should be able to navigate locally to the serve-git server in the browser: Screenshot 2023-09-15 at 5 38 04 PM

Navigate to some repo using the web UI interface http://127.0.0.1:6969/repos/gogs/ Screenshot 2023-09-15 at 5 38 47 PM

Now simulate the git-upload-pack endpoint http://127.0.0.1:6969/repos/gogs/git-upload-pack Screenshot 2023-09-15 at 5 40 46 PM

This will trigger a memory address error in the gitservice go module observable in the src serve-git logging:

DBUG serve-git: 2023/09/15 17:40:15 git service svc=/git-upload-pack protocol= repo=gogs duration=9.499684ms
DBUG serve-git: 2023/09/15 17:40:15 error running git service command args=["-c" "uploadpack.allowFilter=true" "-c" "uploadpack.allowAnySHA1InWant=true" "-c" "pack.windowMemory=100m" "upload-pack" "--stateless-rpc" "--strict" "/Users/warrengifford/test-src-serve/gogs"]: exit status 128
http: panic serving 127.0.0.1:53151: runtime error: invalid memory address or nil pointer dereference
goroutine 324 [running]:
net/http.(*conn).serve.func1()
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:1850 +0xbf
panic({0x2bc4520, 0x503dce0})
    /opt/hostedtoolcache/go/1.19.10/x64/src/runtime/panic.go:890 +0x262
github.com/sourcegraph/sourcegraph/lib/gitservice.(*Handler).ServeHTTP(0xc0009cc960, {0x3f74d58, 0xc0006581c0}, 0xc000c0eb00)
    /home/runner/go/pkg/mod/github.com/sourcegraph/sourcegraph/lib@v0.0.0-20230316093010-26299ec302d0/gitservice/gitservice.go:151 +0x1127
github.com/sourcegraph/src-cli/internal/servegit.(*Serve).handler.func5({0x3f74d58, 0xc0006581c0}, 0xc000c0eb00)
    /home/runner/work/src-cli/src-cli/internal/servegit/serve.go:123 +0x14a
net/http.HandlerFunc.ServeHTTP(0xc000ca3990?, {0x3f74d58?, 0xc0006581c0?}, 0x5744f18?)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2109 +0x2f
net/http.StripPrefix.func1({0x3f74d58, 0xc0006581c0}, 0xc000c0e100)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2152 +0x332
net/http.HandlerFunc.ServeHTTP(0xa41a38?, {0x3f74d58?, 0xc0006581c0?}, 0x10f84a9?)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2109 +0x2f
net/http.(*ServeMux).ServeHTTP(0x0?, {0x3f74d58, 0xc0006581c0}, 0xc000c0e100)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2487 +0x149
github.com/sourcegraph/src-cli/internal/servegit.(*Serve).handler.func6({0x3f74d58?, 0xc0006581c0?}, 0x6766000?)
    /home/runner/work/src-cli/src-cli/internal/servegit/serve.go:131 +0x33
net/http.HandlerFunc.ServeHTTP(0x0?, {0x3f74d58?, 0xc0006581c0?}, 0x1064ece?)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2109 +0x2f
net/http.serverHandler.ServeHTTP({0xc000529170?}, {0x3f74d58, 0xc0006581c0}, 0xc000c0e100)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2947 +0x30c
net/http.(*conn).serve(0xc0002d6be0, {0x3f75eb8, 0xc0009cca80})
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:1991 +0x607
created by net/http.(*Server).Serve
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:3102 +0x4db
DBUG serve-git: 2023/09/15 17:40:15 git service svc=/git-upload-pack protocol= repo=gogs duration=8.90276ms
DBUG serve-git: 2023/09/15 17:40:15 error running git service command args=["-c" "uploadpack.allowFilter=true" "-c" "uploadpack.allowAnySHA1InWant=true" "-c" "pack.windowMemory=100m" "upload-pack" "--stateless-rpc" "--strict" "/Users/warrengifford/test-src-serve/gogs"]: exit status 128
http: panic serving 127.0.0.1:53185: runtime error: invalid memory address or nil pointer dereference
goroutine 572 [running]:
net/http.(*conn).serve.func1()
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:1850 +0xbf
panic({0x2bc4520, 0x503dce0})
    /opt/hostedtoolcache/go/1.19.10/x64/src/runtime/panic.go:890 +0x262
github.com/sourcegraph/sourcegraph/lib/gitservice.(*Handler).ServeHTTP(0xc0009cc960, {0x3f74d58, 0xc000658380}, 0xc000c0ec00)
    /home/runner/go/pkg/mod/github.com/sourcegraph/sourcegraph/lib@v0.0.0-20230316093010-26299ec302d0/gitservice/gitservice.go:151 +0x1127
github.com/sourcegraph/src-cli/internal/servegit.(*Serve).handler.func5({0x3f74d58, 0xc000658380}, 0xc000c0ec00)
    /home/runner/work/src-cli/src-cli/internal/servegit/serve.go:123 +0x14a
net/http.HandlerFunc.ServeHTTP(0xc00053a990?, {0x3f74d58?, 0xc000658380?}, 0x3?)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2109 +0x2f
net/http.StripPrefix.func1({0x3f74d58, 0xc000658380}, 0xc000c0ea00)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2152 +0x332
net/http.HandlerFunc.ServeHTTP(0xa003c0?, {0x3f74d58?, 0xc000658380?}, 0x10f84a9?)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2109 +0x2f
net/http.(*ServeMux).ServeHTTP(0x0?, {0x3f74d58, 0xc000658380}, 0xc000c0ea00)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2487 +0x149
github.com/sourcegraph/src-cli/internal/servegit.(*Serve).handler.func6({0x3f74d58?, 0xc000658380?}, 0x6766000?)
    /home/runner/work/src-cli/src-cli/internal/servegit/serve.go:131 +0x33
net/http.HandlerFunc.ServeHTTP(0x0?, {0x3f74d58?, 0xc000658380?}, 0x1064ece?)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2109 +0x2f
net/http.serverHandler.ServeHTTP({0xc0007baf60?}, {0x3f74d58, 0xc000658380}, 0xc000c0ea00)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2947 +0x30c
net/http.(*conn).serve(0xc000880280, {0x3f75eb8, 0xc0009cca80})
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:1991 +0x607
created by net/http.(*Server).Serve
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:3102 +0x4db
DBUG serve-git: 2023/09/15 17:40:15 git service svc=/git-upload-pack protocol= repo=gogs duration=8.175854ms
DBUG serve-git: 2023/09/15 17:40:15 error running git service command args=["-c" "uploadpack.allowFilter=true" "-c" "uploadpack.allowAnySHA1InWant=true" "-c" "pack.windowMemory=100m" "upload-pack" "--stateless-rpc" "--strict" "/Users/warrengifford/test-src-serve/gogs"]: exit status 128
http: panic serving 127.0.0.1:53186: runtime error: invalid memory address or nil pointer dereference
goroutine 647 [running]:
net/http.(*conn).serve.func1()
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:1850 +0xbf
panic({0x2bc4520, 0x503dce0})
    /opt/hostedtoolcache/go/1.19.10/x64/src/runtime/panic.go:890 +0x262
github.com/sourcegraph/sourcegraph/lib/gitservice.(*Handler).ServeHTTP(0xc0009cc960, {0x3f74d58, 0xc000658540}, 0xc000c0ee00)
    /home/runner/go/pkg/mod/github.com/sourcegraph/sourcegraph/lib@v0.0.0-20230316093010-26299ec302d0/gitservice/gitservice.go:151 +0x1127
github.com/sourcegraph/src-cli/internal/servegit.(*Serve).handler.func5({0x3f74d58, 0xc000658540}, 0xc000c0ee00)
    /home/runner/work/src-cli/src-cli/internal/servegit/serve.go:123 +0x14a
net/http.HandlerFunc.ServeHTTP(0x0?, {0x3f74d58?, 0xc000658540?}, 0x100d5c7?)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2109 +0x2f
net/http.StripPrefix.func1({0x3f74d58, 0xc000658540}, 0xc000c0ed00)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2152 +0x332
net/http.HandlerFunc.ServeHTTP(0xa005c0?, {0x3f74d58?, 0xc000658540?}, 0x10f84a9?)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2109 +0x2f
net/http.(*ServeMux).ServeHTTP(0x0?, {0x3f74d58, 0xc000658540}, 0xc000c0ed00)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2487 +0x149
github.com/sourcegraph/src-cli/internal/servegit.(*Serve).handler.func6({0x3f74d58?, 0xc000658540?}, 0x6766000?)
    /home/runner/work/src-cli/src-cli/internal/servegit/serve.go:131 +0x33
net/http.HandlerFunc.ServeHTTP(0x0?, {0x3f74d58?, 0xc000658540?}, 0x1064ece?)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2109 +0x2f
net/http.serverHandler.ServeHTTP({0xc0007bb860?}, {0x3f74d58, 0xc000658540}, 0xc000c0ed00)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2947 +0x30c
net/http.(*conn).serve(0xc0008803c0, {0x3f75eb8, 0xc0009cca80})
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:1991 +0x607
created by net/http.(*Server).Serve
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:3102 +0x4db
DBUG serve-git: 2023/09/15 17:40:16 git service svc=/git-upload-pack protocol= repo=gogs duration=9.465342ms
DBUG serve-git: 2023/09/15 17:40:16 error running git service command args=["-c" "uploadpack.allowFilter=true" "-c" "uploadpack.allowAnySHA1InWant=true" "-c" "pack.windowMemory=100m" "upload-pack" "--stateless-rpc" "--strict" "/Users/warrengifford/test-src-serve/gogs"]: exit status 128
http: panic serving 127.0.0.1:53187: runtime error: invalid memory address or nil pointer dereference
goroutine 653 [running]:
net/http.(*conn).serve.func1()
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:1850 +0xbf
panic({0x2bc4520, 0x503dce0})
    /opt/hostedtoolcache/go/1.19.10/x64/src/runtime/panic.go:890 +0x262
github.com/sourcegraph/sourcegraph/lib/gitservice.(*Handler).ServeHTTP(0xc0009cc960, {0x3f74d58, 0xc0001861c0}, 0xc0001a2500)
    /home/runner/go/pkg/mod/github.com/sourcegraph/sourcegraph/lib@v0.0.0-20230316093010-26299ec302d0/gitservice/gitservice.go:151 +0x1127
github.com/sourcegraph/src-cli/internal/servegit.(*Serve).handler.func5({0x3f74d58, 0xc0001861c0}, 0xc0001a2500)
    /home/runner/work/src-cli/src-cli/internal/servegit/serve.go:123 +0x14a
net/http.HandlerFunc.ServeHTTP(0xc000bcf990?, {0x3f74d58?, 0xc0001861c0?}, 0x5744108?)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2109 +0x2f
net/http.StripPrefix.func1({0x3f74d58, 0xc0001861c0}, 0xc0001a2400)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2152 +0x332
net/http.HandlerFunc.ServeHTTP(0xa88300?, {0x3f74d58?, 0xc0001861c0?}, 0x10f84a9?)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2109 +0x2f
net/http.(*ServeMux).ServeHTTP(0x0?, {0x3f74d58, 0xc0001861c0}, 0xc0001a2400)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2487 +0x149
github.com/sourcegraph/src-cli/internal/servegit.(*Serve).handler.func6({0x3f74d58?, 0xc0001861c0?}, 0x6764470?)
    /home/runner/work/src-cli/src-cli/internal/servegit/serve.go:131 +0x33
net/http.HandlerFunc.ServeHTTP(0x0?, {0x3f74d58?, 0xc0001861c0?}, 0x1064ece?)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2109 +0x2f
net/http.serverHandler.ServeHTTP({0xc000a389f0?}, {0x3f74d58, 0xc0001861c0}, 0xc0001a2400)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2947 +0x30c
net/http.(*conn).serve(0xc000880780, {0x3f75eb8, 0xc0009cca80})
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:1991 +0x607
created by net/http.(*Server).Serve
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:3102 +0x4db
DBUG serve-git: 2023/09/15 17:40:16 git service svc=/git-upload-pack protocol= repo=gogs duration=8.467462ms
DBUG serve-git: 2023/09/15 17:40:16 error running git service command args=["-c" "uploadpack.allowFilter=true" "-c" "uploadpack.allowAnySHA1InWant=true" "-c" "pack.windowMemory=100m" "upload-pack" "--stateless-rpc" "--strict" "/Users/warrengifford/test-src-serve/gogs"]: exit status 128
http: panic serving 127.0.0.1:53188: runtime error: invalid memory address or nil pointer dereference
goroutine 654 [running]:
net/http.(*conn).serve.func1()
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:1850 +0xbf
panic({0x2bc4520, 0x503dce0})
    /opt/hostedtoolcache/go/1.19.10/x64/src/runtime/panic.go:890 +0x262
github.com/sourcegraph/sourcegraph/lib/gitservice.(*Handler).ServeHTTP(0xc0009cc960, {0x3f74d58, 0xc0001868c0}, 0xc0001a2800)
    /home/runner/go/pkg/mod/github.com/sourcegraph/sourcegraph/lib@v0.0.0-20230316093010-26299ec302d0/gitservice/gitservice.go:151 +0x1127
github.com/sourcegraph/src-cli/internal/servegit.(*Serve).handler.func5({0x3f74d58, 0xc0001868c0}, 0xc0001a2800)
    /home/runner/work/src-cli/src-cli/internal/servegit/serve.go:123 +0x14a
net/http.HandlerFunc.ServeHTTP(0x0?, {0x3f74d58?, 0xc0001868c0?}, 0x100d5c7?)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2109 +0x2f
net/http.StripPrefix.func1({0x3f74d58, 0xc0001868c0}, 0xc000c0ef00)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2152 +0x332
net/http.HandlerFunc.ServeHTTP(0xa00740?, {0x3f74d58?, 0xc0001868c0?}, 0x10f84a9?)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2109 +0x2f
net/http.(*ServeMux).ServeHTTP(0x0?, {0x3f74d58, 0xc0001868c0}, 0xc000c0ef00)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2487 +0x149
github.com/sourcegraph/src-cli/internal/servegit.(*Serve).handler.func6({0x3f74d58?, 0xc0001868c0?}, 0x6764470?)
    /home/runner/work/src-cli/src-cli/internal/servegit/serve.go:131 +0x33
net/http.HandlerFunc.ServeHTTP(0x0?, {0x3f74d58?, 0xc0001868c0?}, 0x1064ece?)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2109 +0x2f
net/http.serverHandler.ServeHTTP({0xc0007bbd70?}, {0x3f74d58, 0xc0001868c0}, 0xc000c0ef00)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2947 +0x30c
net/http.(*conn).serve(0xc0008808c0, {0x3f75eb8, 0xc0009cca80})
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:1991 +0x607
created by net/http.(*Server).Serve
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:3102 +0x4db
DBUG serve-git: 2023/09/15 17:40:16 git service svc=/git-upload-pack protocol= repo=gogs duration=8.130046ms
DBUG serve-git: 2023/09/15 17:40:16 error running git service command args=["-c" "uploadpack.allowFilter=true" "-c" "uploadpack.allowAnySHA1InWant=true" "-c" "pack.windowMemory=100m" "upload-pack" "--stateless-rpc" "--strict" "/Users/warrengifford/test-src-serve/gogs"]: exit status 128
http: panic serving 127.0.0.1:53189: runtime error: invalid memory address or nil pointer dereference
goroutine 622 [running]:
net/http.(*conn).serve.func1()
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:1850 +0xbf
panic({0x2bc4520, 0x503dce0})
    /opt/hostedtoolcache/go/1.19.10/x64/src/runtime/panic.go:890 +0x262
github.com/sourcegraph/sourcegraph/lib/gitservice.(*Handler).ServeHTTP(0xc0009cc960, {0x3f74d58, 0xc000186a80}, 0xc0001a2a00)
    /home/runner/go/pkg/mod/github.com/sourcegraph/sourcegraph/lib@v0.0.0-20230316093010-26299ec302d0/gitservice/gitservice.go:151 +0x1127
github.com/sourcegraph/src-cli/internal/servegit.(*Serve).handler.func5({0x3f74d58, 0xc000186a80}, 0xc0001a2a00)
    /home/runner/work/src-cli/src-cli/internal/servegit/serve.go:123 +0x14a
net/http.HandlerFunc.ServeHTTP(0x0?, {0x3f74d58?, 0xc000186a80?}, 0x100d5c7?)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2109 +0x2f
net/http.StripPrefix.func1({0x3f74d58, 0xc000186a80}, 0xc0001a2900)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2152 +0x332
net/http.HandlerFunc.ServeHTTP(0xa88600?, {0x3f74d58?, 0xc000186a80?}, 0x10f84a9?)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2109 +0x2f
net/http.(*ServeMux).ServeHTTP(0x0?, {0x3f74d58, 0xc000186a80}, 0xc0001a2900)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2487 +0x149
github.com/sourcegraph/src-cli/internal/servegit.(*Serve).handler.func6({0x3f74d58?, 0xc000186a80?}, 0x6764470?)
    /home/runner/work/src-cli/src-cli/internal/servegit/serve.go:131 +0x33
net/http.HandlerFunc.ServeHTTP(0x0?, {0x3f74d58?, 0xc000186a80?}, 0x1064ece?)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2109 +0x2f
net/http.serverHandler.ServeHTTP({0xc000a39350?}, {0x3f74d58, 0xc000186a80}, 0xc0001a2900)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2947 +0x30c
net/http.(*conn).serve(0xc000145540, {0x3f75eb8, 0xc0009cca80})
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:1991 +0x607
created by net/http.(*Server).Serve
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:3102 +0x4db
DBUG serve-git: 2023/09/15 17:40:21 git service svc=/git-upload-pack protocol= repo=gogs duration=8.403771ms
DBUG serve-git: 2023/09/15 17:40:21 error running git service command args=["-c" "uploadpack.allowFilter=true" "-c" "uploadpack.allowAnySHA1InWant=true" "-c" "pack.windowMemory=100m" "upload-pack" "--stateless-rpc" "--strict" "/Users/warrengifford/test-src-serve/gogs"]: exit status 128
http: panic serving 127.0.0.1:53190: runtime error: invalid memory address or nil pointer dereference
goroutine 660 [running]:
net/http.(*conn).serve.func1()
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:1850 +0xbf
panic({0x2bc4520, 0x503dce0})
    /opt/hostedtoolcache/go/1.19.10/x64/src/runtime/panic.go:890 +0x262
github.com/sourcegraph/sourcegraph/lib/gitservice.(*Handler).ServeHTTP(0xc0009cc960, {0x3f74d58, 0xc000186c40}, 0xc0001a2d00)
    /home/runner/go/pkg/mod/github.com/sourcegraph/sourcegraph/lib@v0.0.0-20230316093010-26299ec302d0/gitservice/gitservice.go:151 +0x1127
github.com/sourcegraph/src-cli/internal/servegit.(*Serve).handler.func5({0x3f74d58, 0xc000186c40}, 0xc0001a2d00)
    /home/runner/work/src-cli/src-cli/internal/servegit/serve.go:123 +0x14a
net/http.HandlerFunc.ServeHTTP(0x0?, {0x3f74d58?, 0xc000186c40?}, 0x100d5c7?)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2109 +0x2f
net/http.StripPrefix.func1({0x3f74d58, 0xc000186c40}, 0xc0001a2b00)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2152 +0x332
net/http.HandlerFunc.ServeHTTP(0xa887c0?, {0x3f74d58?, 0xc000186c40?}, 0x10f84a9?)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2109 +0x2f
net/http.(*ServeMux).ServeHTTP(0x0?, {0x3f74d58, 0xc000186c40}, 0xc0001a2b00)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2487 +0x149
github.com/sourcegraph/src-cli/internal/servegit.(*Serve).handler.func6({0x3f74d58?, 0xc000186c40?}, 0x6764470?)
    /home/runner/work/src-cli/src-cli/internal/servegit/serve.go:131 +0x33
net/http.HandlerFunc.ServeHTTP(0x0?, {0x3f74d58?, 0xc000186c40?}, 0x1064ece?)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2109 +0x2f
net/http.serverHandler.ServeHTTP({0xc000a39830?}, {0x3f74d58, 0xc000186c40}, 0xc0001a2b00)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2947 +0x30c
net/http.(*conn).serve(0xc0001457c0, {0x3f75eb8, 0xc0009cca80})
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:1991 +0x607
created by net/http.(*Server).Serve
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:3102 +0x4db
DBUG serve-git: 2023/09/15 17:40:21 git service svc=/git-upload-pack protocol= repo=gogs duration=7.809471ms
DBUG serve-git: 2023/09/15 17:40:21 error running git service command args=["-c" "uploadpack.allowFilter=true" "-c" "uploadpack.allowAnySHA1InWant=true" "-c" "pack.windowMemory=100m" "upload-pack" "--stateless-rpc" "--strict" "/Users/warrengifford/test-src-serve/gogs"]: exit status 128
http: panic serving 127.0.0.1:53191: runtime error: invalid memory address or nil pointer dereference
goroutine 661 [running]:
net/http.(*conn).serve.func1()
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:1850 +0xbf
panic({0x2bc4520, 0x503dce0})
    /opt/hostedtoolcache/go/1.19.10/x64/src/runtime/panic.go:890 +0x262
github.com/sourcegraph/sourcegraph/lib/gitservice.(*Handler).ServeHTTP(0xc0009cc960, {0x3f74d58, 0xc000186e00}, 0xc0001a2e00)
    /home/runner/go/pkg/mod/github.com/sourcegraph/sourcegraph/lib@v0.0.0-20230316093010-26299ec302d0/gitservice/gitservice.go:151 +0x1127
github.com/sourcegraph/src-cli/internal/servegit.(*Serve).handler.func5({0x3f74d58, 0xc000186e00}, 0xc0001a2e00)
    /home/runner/work/src-cli/src-cli/internal/servegit/serve.go:123 +0x14a
net/http.HandlerFunc.ServeHTTP(0x0?, {0x3f74d58?, 0xc000186e00?}, 0x100d5c7?)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2109 +0x2f
net/http.StripPrefix.func1({0x3f74d58, 0xc000186e00}, 0xc0001a2c00)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2152 +0x332
net/http.HandlerFunc.ServeHTTP(0x8b2a40?, {0x3f74d58?, 0xc000186e00?}, 0x10f84a9?)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2109 +0x2f
net/http.(*ServeMux).ServeHTTP(0x0?, {0x3f74d58, 0xc000186e00}, 0xc0001a2c00)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2487 +0x149
github.com/sourcegraph/src-cli/internal/servegit.(*Serve).handler.func6({0x3f74d58?, 0xc000186e00?}, 0x6764470?)
    /home/runner/work/src-cli/src-cli/internal/servegit/serve.go:131 +0x33
net/http.HandlerFunc.ServeHTTP(0x0?, {0x3f74d58?, 0xc000186e00?}, 0x1064ece?)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2109 +0x2f
net/http.serverHandler.ServeHTTP({0xc000a398f0?}, {0x3f74d58, 0xc000186e00}, 0xc0001a2c00)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2947 +0x30c
net/http.(*conn).serve(0xc000145a40, {0x3f75eb8, 0xc0009cca80})
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:1991 +0x607
created by net/http.(*Server).Serve
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:3102 +0x4db
DBUG serve-git: 2023/09/15 17:40:21 git service svc=/git-upload-pack protocol= repo=gogs duration=7.864791ms
DBUG serve-git: 2023/09/15 17:40:21 error running git service command args=["-c" "uploadpack.allowFilter=true" "-c" "uploadpack.allowAnySHA1InWant=true" "-c" "pack.windowMemory=100m" "upload-pack" "--stateless-rpc" "--strict" "/Users/warrengifford/test-src-serve/gogs"]: exit status 128
http: panic serving 127.0.0.1:53192: runtime error: invalid memory address or nil pointer dereference
goroutine 672 [running]:
net/http.(*conn).serve.func1()
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:1850 +0xbf
panic({0x2bc4520, 0x503dce0})
    /opt/hostedtoolcache/go/1.19.10/x64/src/runtime/panic.go:890 +0x262
github.com/sourcegraph/sourcegraph/lib/gitservice.(*Handler).ServeHTTP(0xc0009cc960, {0x3f74d58, 0xc000186fc0}, 0xc0001a3000)
    /home/runner/go/pkg/mod/github.com/sourcegraph/sourcegraph/lib@v0.0.0-20230316093010-26299ec302d0/gitservice/gitservice.go:151 +0x1127
github.com/sourcegraph/src-cli/internal/servegit.(*Serve).handler.func5({0x3f74d58, 0xc000186fc0}, 0xc0001a3000)
    /home/runner/work/src-cli/src-cli/internal/servegit/serve.go:123 +0x14a
net/http.HandlerFunc.ServeHTTP(0x0?, {0x3f74d58?, 0xc000186fc0?}, 0x100d5c7?)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2109 +0x2f
net/http.StripPrefix.func1({0x3f74d58, 0xc000186fc0}, 0xc0001a2f00)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2152 +0x332
net/http.HandlerFunc.ServeHTTP(0xa88ac0?, {0x3f74d58?, 0xc000186fc0?}, 0x10f84a9?)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2109 +0x2f
net/http.(*ServeMux).ServeHTTP(0x0?, {0x3f74d58, 0xc000186fc0}, 0xc0001a2f00)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2487 +0x149
github.com/sourcegraph/src-cli/internal/servegit.(*Serve).handler.func6({0x3f74d58?, 0xc000186fc0?}, 0x6764470?)
    /home/runner/work/src-cli/src-cli/internal/servegit/serve.go:131 +0x33
net/http.HandlerFunc.ServeHTTP(0x0?, {0x3f74d58?, 0xc000186fc0?}, 0x1064ece?)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2109 +0x2f
net/http.serverHandler.ServeHTTP({0xc000331350?}, {0x3f74d58, 0xc000186fc0}, 0xc0001a2f00)
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:2947 +0x30c
net/http.(*conn).serve(0xc000145cc0, {0x3f75eb8, 0xc0009cca80})
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:1991 +0x607
created by net/http.(*Server).Serve
    /opt/hostedtoolcache/go/1.19.10/x64/src/net/http/server.go:3102 +0x4db
DBUG serve-git: 2023/09/15 17:40:32 git service svc=/info/refs protocol=version=2 repo=flamego/.git duration=9.946097ms
DBUG serve-git: 2023/09/15 17:40:32 git service svc=/info/refs protocol=version=2 repo=gogs/.git duration=10.247925ms
DBUG serve-git: 2023/09/15 17:40:32 git service svc=/git-upload-pack protocol=version=2 repo=flamego/.git duration=9.980429ms
DBUG serve-git: 2023/09/15 17:40:32 git service svc=/info/refs protocol=version=2 repo=mach/.git duration=8.510203ms
DBUG serve-git: 2023/09/15 17:40:32 git service svc=/git-upload-pack protocol=version=2 repo=gogs/.git duration=11.21872ms
DBUG serve-git: 2023/09/15 17:40:32 git service svc=/git-upload-pack protocol=version=2 repo=mach/.git duration=9.226501ms

Screenshot 2023-09-15 at 5 40 46 PM

Problem

This is artificially generated, but the error has been observed in the wild. At the time of opening this issue I'm not sure why this path gets hit sometimes and under what conditions it will get hit and fail. In theory it should come up during cloning but it isn't regularly failing with small repos on my mac.

If you would like immediate help on this, please email support@sourcegraph.com (you can still create the issue, but there are no SLAs on issues like there are for support requests).

/cc @sourcegraph/source

keegancsmith commented 1 year ago

@DaedalusG this is fixed in main in the src-cli repo: https://github.com/sourcegraph/src-cli/pull/1037

eseliger commented 1 year ago

@DaedalusG is this ticket okay to close?

DaedalusG commented 1 year ago

@eseliger let me validate it after the new version is released? I think there's a deeper bug in here potentially that I can't drill into until the logging error is resolved

eseliger commented 1 year ago

sure! assigned you :)