Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Unexpected panic when running sg lint #62471

@chrsmith

Description

@chrsmith

Not going to lie. I feel really bad that my current branch is so messed up that the sg tool literally dies when trying to look at it. 😭 (And this does seem reproducible. I'll keep the commit locally in case you need it for a repro.)

The full output:

 ~/go/src/github.com/sourcegraph/sourcegraph % sg lint --fix client
👉 Fixing checks from target: client, format
✅ Running checks  ██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████  100%
│                                                                                                                                                                                              
├── 1. client  Running checks...                                                                                                                                                            34s
└── 2. format  Done!                                                                                                                                                                        34s
⚠️ Encountered panic - please open an issue with the command output:
        https://github.com/sourcegraph/sourcegraph/issues/new?template=sg_bug.md
❌ panic: panic: runtime error: invalid memory address or nil pointer dereference
stacktrace:
goroutine 96 [running]:
runtime/debug.Stack()
        runtime/debug/stack.go:24 +0x64
github.com/sourcegraph/conc/panics.NewRecovered(0x1, {0x109ec6d60, 0x10ced2250})
        github.com/sourcegraph/conc@v0.3.1-0.20240108182409-4afefce20f9b/panics/panics.go:59 +0x74
github.com/sourcegraph/conc/panics.(*Catcher).tryRecover(0x14002da3330)
        github.com/sourcegraph/conc@v0.3.1-0.20240108182409-4afefce20f9b/panics/panics.go:28 +0x58
panic({0x109ec6d60?, 0x10ced2250?})
        runtime/panic.go:770 +0x124
go.opentelemetry.io/otel/sdk/trace.(*recordingSpan).End.deferwrap1()
        go.opentelemetry.io/otel/sdk@v1.24.0/trace/span.go:405 +0x2c
go.opentelemetry.io/otel/sdk/trace.(*recordingSpan).End(0x14001600180, {0x0, 0x0, 0x14002f539b0?})
        go.opentelemetry.io/otel/sdk@v1.24.0/trace/span.go:443 +0x8ac
panic({0x109ec6d60?, 0x10ced2250?})
        runtime/panic.go:770 +0x124
github.com/sourcegraph/sourcegraph/dev/sg/linters.init.runScriptSerialized.func19({0x10a5d43f0, 0x14002f0f680}, 0x14002f144c0, 0x14002f0f680?)
        github.com/sourcegraph/sourcegraph/dev/sg/linters/linters.go:157 +0x90
github.com/sourcegraph/sourcegraph/dev/sg/internal/check.(*Check[...]).Update(...)
        github.com/sourcegraph/sourcegraph/dev/sg/internal/check/category.go:36
github.com/sourcegraph/sourcegraph/dev/sg/internal/check.(*Runner[...]).runAllCategoryChecks.func8.1()
        github.com/sourcegraph/sourcegraph/dev/sg/internal/check/runner.go:392 +0x44c
github.com/sourcegraph/conc/pool.(*ErrorPool).Go.func1()
        github.com/sourcegraph/conc@v0.3.1-0.20240108182409-4afefce20f9b/pool/error_pool.go:30 +0x30
github.com/sourcegraph/conc/pool.(*Pool).worker(0x14002da3320, 0x0?)
        github.com/sourcegraph/conc@v0.3.1-0.20240108182409-4afefce20f9b/pool/pool.go:156 +0x5c
github.com/sourcegraph/conc/pool.(*Pool).Go.func1()
        github.com/sourcegraph/conc@v0.3.1-0.20240108182409-4afefce20f9b/pool/pool.go:51 +0x24
github.com/sourcegraph/conc/panics.(*Catcher).Try(0x0?, 0x1042476a8?)
        github.com/sourcegraph/conc@v0.3.1-0.20240108182409-4afefce20f9b/panics/panics.go:23 +0x50
github.com/sourcegraph/conc.(*WaitGroup).Go.func1()
        github.com/sourcegraph/conc@v0.3.1-0.20240108182409-4afefce20f9b/waitgroup.go:32 +0x58
created by github.com/sourcegraph/conc.(*WaitGroup).Go in goroutine 117
        github.com/sourcegraph/conc@v0.3.1-0.20240108182409-4afefce20f9b/waitgroup.go:30 +0x7c


stacktrace:
goroutine 117 [running]:
runtime/debug.Stack()
        runtime/debug/stack.go:24 +0x64
github.com/sourcegraph/conc/panics.NewRecovered(0x1, {0x109f1fe80, 0x1400063d880})
        github.com/sourcegraph/conc@v0.3.1-0.20240108182409-4afefce20f9b/panics/panics.go:59 +0x74
github.com/sourcegraph/conc/panics.(*Catcher).tryRecover(0x14000820630)
        github.com/sourcegraph/conc@v0.3.1-0.20240108182409-4afefce20f9b/panics/panics.go:28 +0x58
panic({0x109f1fe80?, 0x1400063d880?})
        runtime/panic.go:770 +0x124
github.com/sourcegraph/conc/stream.(*Stream).Go.func1.1()
        github.com/sourcegraph/conc@v0.3.1-0.20240108182409-4afefce20f9b/stream/stream.go:79 +0x68
panic({0x109f1fe80?, 0x1400063d880?})
        runtime/panic.go:770 +0x124
go.opentelemetry.io/otel/sdk/trace.(*recordingSpan).End.deferwrap1()
        go.opentelemetry.io/otel/sdk@v1.24.0/trace/span.go:405 +0x2c
go.opentelemetry.io/otel/sdk/trace.(*recordingSpan).End(0x14001478d80, {0x0, 0x0, 0x14000684e00?})
        go.opentelemetry.io/otel/sdk@v1.24.0/trace/span.go:443 +0x8ac
panic({0x109f1fe80?, 0x1400063d880?})
        runtime/panic.go:770 +0x124
github.com/sourcegraph/conc/panics.(*Catcher).Repanic(...)
        github.com/sourcegraph/conc@v0.3.1-0.20240108182409-4afefce20f9b/panics/panics.go:38
github.com/sourcegraph/conc.(*WaitGroup).Wait(0x14002da3320)
        github.com/sourcegraph/conc@v0.3.1-0.20240108182409-4afefce20f9b/waitgroup.go:42 +0x5c
github.com/sourcegraph/conc/pool.(*Pool).Wait(0x14002da3320)
        github.com/sourcegraph/conc@v0.3.1-0.20240108182409-4afefce20f9b/pool/pool.go:81 +0x60
github.com/sourcegraph/conc/pool.(*ErrorPool).Wait(0x14002da3320)
        github.com/sourcegraph/conc@v0.3.1-0.20240108182409-4afefce20f9b/pool/error_pool.go:37 +0x24
github.com/sourcegraph/sourcegraph/dev/sg/internal/check.(*Runner[...]).runAllCategoryChecks.func8()
        github.com/sourcegraph/sourcegraph/dev/sg/internal/check/runner.go:422 +0x4d0
github.com/sourcegraph/conc/stream.(*Stream).Go.func1()
        github.com/sourcegraph/conc@v0.3.1-0.20240108182409-4afefce20f9b/stream/stream.go:84 +0x58
github.com/sourcegraph/conc/pool.(*Pool).worker(0x14000820620, 0x0?)
        github.com/sourcegraph/conc@v0.3.1-0.20240108182409-4afefce20f9b/pool/pool.go:156 +0x5c
github.com/sourcegraph/conc/pool.(*Pool).Go.func1()
        github.com/sourcegraph/conc@v0.3.1-0.20240108182409-4afefce20f9b/pool/pool.go:51 +0x24
github.com/sourcegraph/conc/panics.(*Catcher).Try(0x0?, 0x0?)
        github.com/sourcegraph/conc@v0.3.1-0.20240108182409-4afefce20f9b/panics/panics.go:23 +0x50
github.com/sourcegraph/conc.(*WaitGroup).Go.func1()
        github.com/sourcegraph/conc@v0.3.1-0.20240108182409-4afefce20f9b/waitgroup.go:32 +0x58
created by github.com/sourcegraph/conc.(*WaitGroup).Go in goroutine 1
        github.com/sourcegraph/conc@v0.3.1-0.20240108182409-4afefce20f9b/waitgroup.go:30 +0x7c

:
github.com/sourcegraph/sourcegraph/dev/sg/internal/check.(*Runner[...]).runAllCategoryChecks
        github.com/sourcegraph/sourcegraph/dev/sg/internal/check/runner.go:425
github.com/sourcegraph/sourcegraph/dev/sg/internal/check.(*Runner[...]).Fix
        github.com/sourcegraph/sourcegraph/dev/sg/internal/check/runner.go:121
main.init.lintTargets.Commands.func65
        github.com/sourcegraph/sourcegraph/dev/sg/sg_lint.go:169
main.main
        github.com/sourcegraph/sourcegraph/dev/sg/main.go:40

The code in question. If I omit --fix it will fail on the runner.Check instead of runner.Fix. So I'm guessing this is rooted in the client linter code somehow?

    runner := linters.NewRunner(std.Out, generateAnnotations.Get(cmd), lintTargets...)
    if lintFix.Get(cmd) {
     std.Out.WriteNoticef("Fixing checks from target: %s", strings.Join(targets, ", "))
     return runner.Fix(cmd.Context, repoState)
    }
    runner.FailFast = lintFailFast.Get(cmd)
    std.Out.WriteNoticef("Running checks from target: %s", strings.Join(targets, ", "))
    return runner.Check(cmd.Context, repoState)

Metadata

Metadata

Assignees

Labels

bugAn error, flaw or fault that produces an incorrect or unexpected result, or behavior.team/dev-infra

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions