Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: panic when concurrency=0 #4477

Merged
merged 1 commit into from
Mar 10, 2024
Merged

fix: panic when concurrency=0 #4477

merged 1 commit into from
Mar 10, 2024

Conversation

ldez
Copy link
Member

@ldez ldez commented Mar 10, 2024

When I created #4441, I tested the PR but I forgot that the default value is not 0 but the number of CPUs.

But when you set explicitly the default to 0, it panics:

$ go run ./cmd/golangci-lint run -j 0
c.cfg.Run.Concurrency 0
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x1536a36]

goroutine 1 [running]:
go.uber.org/automaxprocs/maxprocs.Set({0xc000295c00, 0x1, 0xc000295c00?})
        /home/ldez/sources/go/pkg/mod/go.uber.org/automaxprocs@v1.5.3/maxprocs/maxprocs.go:89 +0x76
github.com/golangci/golangci-lint/pkg/commands.(*runCommand).persistentPreRunE(0xc0002a0ea0, 0xc00038c908, {0x93f76a?, 0xc0003c2600?, 0xc0003c2600?})
        /home/ldez/sources/go/src/github.com/golangci/golangci-lint/pkg/commands/run.go:164 +0x1b5
github.com/spf13/cobra.(*Command).execute(0xc00038c908, {0xc000f11a80, 0x2, 0x2})
        /home/ldez/sources/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:915 +0x764
github.com/spf13/cobra.(*Command).ExecuteC(0xc00038c308)
        /home/ldez/sources/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:1068 +0x3a5
github.com/spf13/cobra.(*Command).Execute(...)
        /home/ldez/sources/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:992
github.com/golangci/golangci-lint/pkg/commands.(*rootCommand).Execute(0xc0001f7590)
        /home/ldez/sources/go/src/github.com/golangci/golangci-lint/pkg/commands/root.go:83 +0x3d
github.com/golangci/golangci-lint/pkg/commands.Execute({{0x1a921f8, 0x8}, {0x1aeb0af, 0x7}, {0xc00030e330, 0x16}, {0x1817868, 0x9}})
        /home/ldez/sources/go/src/github.com/golangci/golangci-lint/pkg/commands/root.go:18 +0x5a
main.main()
        /home/ldez/sources/go/src/github.com/golangci/golangci-lint/cmd/golangci-lint/main.go:39 +0x1d1
exit status 2

I also updated the documentation based on the Go official doc about GOMAXPROCS: https://pkg.go.dev/runtime

@ldez ldez added the bug Something isn't working label Mar 10, 2024
@ldez ldez added this to the next milestone Mar 10, 2024
@ldez ldez merged commit c902b8e into golangci:master Mar 10, 2024
12 checks passed
@ldez ldez deleted the fix/max-procs branch March 10, 2024 14:43
.golangci.reference.yml Show resolved Hide resolved
pkg/commands/run.go Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants