linguist: panic: runtime error: index out of range [0] with length 0
We've seen Gitaly crash in production with the new linguist implementation: gitlab-com/gl-infra/production#7864 (closed)
The error that occurred:
2022-10-12_13:31:32.57689 praefect-gitaly-0 : panic: runtime error: index out of range [0] with length 0
2022-10-12_13:31:32.57692 praefect-gitaly-0 :
2022-10-12_13:31:32.57693 praefect-gitaly-0 : goroutine 153 [running]:
2022-10-12_13:31:32.57693 praefect-gitaly-0 : github.com/go-git/go-git/v5/plumbing/format/gitattributes.(*pattern).Match(0x1434960?, {0xc009d10bd0?, 0xc003ee802a?, 0x11?})
2022-10-12_13:31:32.57693 praefect-gitaly-0 : /home/toon/.local/share/go/pkg/mod/github.com/go-git/go-git/v5@v5.3.0/plumbing/format/gitattributes/pattern.go:56 +0x319
2022-10-12_13:31:32.57693 praefect-gitaly-0 : github.com/go-git/go-git/v5/plumbing/format/gitattributes.(*matcher).Match(0xc007a57620, {0xc009d10bd0, 0x3, 0x3}, {0xc009ad36d0?, 0x5, 0x0?})
2022-10-12_13:31:32.57694 praefect-gitaly-0 : /home/toon/.local/share/go/pkg/mod/github.com/go-git/go-git/v5@v5.3.0/plumbing/format/gitattributes/matcher.go:58 +0xea
2022-10-12_13:31:32.57694 praefect-gitaly-0 : gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/linguist.newFileInstance({0xc009d26140, 0x1a}, {0x857e220, 0xc007a57620})
2022-10-12_13:31:32.57694 praefect-gitaly-0 : /home/toon/devel/gdk/gitaly/internal/gitaly/linguist/file_instance.go:27 +0xee
2022-10-12_13:31:32.57694 praefect-gitaly-0 : gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/linguist.(*Instance).enryStats.func1(0xc003cdfee0?)
2022-10-12_13:31:32.57694 praefect-gitaly-0 : /home/toon/devel/gdk/gitaly/internal/gitaly/linguist/linguist.go:141 +0x45
2022-10-12_13:31:32.57695 praefect-gitaly-0 : gitlab.com/gitlab-org/gitaly/v15/internal/git/gitpipe.LsTree.func1()
2022-10-12_13:31:32.57695 praefect-gitaly-0 : /home/toon/devel/gdk/gitaly/internal/git/gitpipe/ls_tree.go:122 +0x899
2022-10-12_13:31:32.57695 praefect-gitaly-0 : created by gitlab.com/gitlab-org/gitaly/v15/internal/git/gitpipe.LsTree
2022-10-12_13:31:32.57695 praefect-gitaly-0 : /home/toon/devel/gdk/gitaly/internal/git/gitpipe/ls_tree.go:65 +0x157
2022-10-12_13:31:32.59191 praefect : {"correlation_id":"01GF6699QGF68VRVHMNSHJ06SK","error":"rpc error: code = Unavailable desc = error reading from server: EOF","grpc.code":"Unavailable","grpc.meta.auth_version":"v2","grpc.meta.client_name":"gitlab-web","grpc.meta.deadline_type":"unknown","grpc.meta.method_type":"bidi_stream","grpc.method":"CommitLanguages","grpc.request.deadline":"2022-10-12T21:31:31.952","grpc.request.fullMethod":"/gitaly.CommitService/CommitLanguages","grpc.service":"gitaly.CommitService","grpc.start_time":"2022-10-12T15:31:31.952","grpc.time_ms":638.831,"level":"warning","msg":"finished streaming call with code Unavailable","peer.address":"@","pid":907247,"relative_path":"@hashed/a2/18/a21855da08cb102d1d217c53dc5824a3a795c1c1a44e971bf01ab9da3a2acbbf.git","route":{"replica_path":"@cluster/repositories/1d/0e/154","storage":"praefect-internal-0"},"sentry.skip":{},"span.kind":"server","system":"grpc","time":"2022-10-12T13:31:32.591Z","trace.sampled":"true","trace.spanid":"7141fbfdcd646330","trace.traceid":"7141fbfdcd646330","virtual_storage":"default"}
2022-10-12_13:31:32.77697 praefect-gitaly-0 : time="2022-10-12T15:31:32+02:00" level=info msg="Starting Gitaly, version 15.4.0-rc2-150-g847af5af1"
One of the repos triggering this crash is: https://gitlab.com/GodotBuilder/godot3