Closed demoManito closed 3 months ago
Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.
Hello,
can you provide a reproducible code example and your configuration?
This issue doesn't provide:
master
, latest
, and devel
are not precise versions)With the stacktrace, the only things that I can know are it may be related to the govet
rule httpresponse
or golang.org/x/tools@v0.19.0
.
Without more information, it can take days to find out how to recreate the problem (if the problem can be recreated) and how to fix it.
If you are facing the same problem, the best way to contribute is to provide the following information:
A code example or link to a public repository.
golangci-lint --version
# or exact commit reference
cat .golangci.yml
go version && go env
golangci-lint cache clean
golangci-lint run -v
I have this same issue on https://gitlab.com/accumulatenetwork/accumulate/ when I update to golangci-lint bleeding edge (for the new plugin system). Once I work around it for production I'll try to make a repro branch.
Ultimately it appears there's a bug in golang.org/x/tools.
golangci-repro-4482 reproduces the panic on my PC. Reverting golang.org/x/tools to v0.18.0 resolves the issue. Here's the full log:
INFO [config_reader] Config search paths: [./ /home/firelizzard/src/Accumulate/accumulate /home/firelizzard/src/Accumulate /home/firelizzard/src /home/firelizzard /home /] INFO [config_reader] Used config file .golangci.yml INFO Loaded : rangevarref INFO Loaded : noprint INFO Loaded : nodebug INFO [lintersdb] Active 1 linters: [govet] INFO [loader] Go packages loading at mode 575 (name|compiled_files|deps|exports_file|files|imports|types_sizes) took 448.562894ms INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 45.95519ms INFO [linters_context/goanalysis] analyzers took 636.641834ms with top 10 stages: inspect: 117.639198ms, printf: 89.964436ms, ctrlflow: 62.623472ms, copylocks: 53.980913ms, assign: 29.201073ms, lostcancel: 26.764156ms, bools: 21.786709ms, composites: 18.945616ms, unsafeptr: 17.460426ms, unreachable: 15.820847ms ERRO [runner] Panic: httpresponse: package "simulator" (isInitialPkg: true, needAnalyzeSource: true): runtime error: invalid memory address or nil pointer dereference: goroutine 28424 [running]: runtime/debug.Stack() /home/firelizzard/sdk/go1.22.1/src/runtime/debug/stack.go:24 +0x5e github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func1() /home/firelizzard/go/pkg/mod/github.com/golangci/golangci-lint@v1.56.3-0.20240311192827-d18acc5b51ed/pkg/golinters/goanalysis/runner_action.go:108 +0x277 panic({0x16e86a0?, 0x2327480?}) /home/firelizzard/sdk/go1.22.1/src/runtime/panic.go:770 +0x132 go/types.(*Named).Obj(...) /home/firelizzard/sdk/go1.22.1/src/go/types/named.go:295 golang.org/x/tools/go/analysis/passes/internal/analysisutil.IsNamedType({0x1afa470?, 0x0?}, {0x185e739, 0x8}, {0xc0027ebaf8, 0x1, 0x928645?}) /home/firelizzard/go/pkg/mod/golang.org/x/tools@v0.19.0/go/analysis/passes/internal/analysisutil/util.go:123 +0x49 golang.org/x/tools/go/analysis/passes/httpresponse.isHTTPFuncOrMethodOnClient(0xc00dd04240, 0xc014064100?) /home/firelizzard/go/pkg/mod/golang.org/x/tools@v0.19.0/go/analysis/passes/httpresponse/httpresponse.go:122 +0xfb golang.org/x/tools/go/analysis/passes/httpresponse.run.func1({0x1af9b10?, 0xc00cdc7c80?}, 0x10?, {0xc014064100, 0xc, 0x10}) /home/firelizzard/go/pkg/mod/golang.org/x/tools@v0.19.0/go/analysis/passes/httpresponse/httpresponse.go:62 +0x73 golang.org/x/tools/go/ast/inspector.(*Inspector).WithStack(0xc0124d1d88, {0xc0034c64b8?, 0x2353000?, 0x600?}, 0xc00164bcc8) /home/firelizzard/go/pkg/mod/golang.org/x/tools@v0.19.0/go/ast/inspector/inspector.go:148 +0x188 golang.org/x/tools/go/analysis/passes/httpresponse.run(0xc01df8bc70) /home/firelizzard/go/pkg/mod/golang.org/x/tools@v0.19.0/go/analysis/passes/httpresponse/httpresponse.go:57 +0x112 github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyze(0xc00353b5b0) /home/firelizzard/go/pkg/mod/github.com/golangci/golangci-lint@v1.56.3-0.20240311192827-d18acc5b51ed/pkg/golinters/goanalysis/runner_action.go:190 +0xa02 github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func2() /home/firelizzard/go/pkg/mod/github.com/golangci/golangci-lint@v1.56.3-0.20240311192827-d18acc5b51ed/pkg/golinters/goanalysis/runner_action.go:112 +0x17 github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0xc00259e910, {0x18a8df4, 0xc}, 0xc0034c6748) /home/firelizzard/go/pkg/mod/github.com/golangci/golangci-lint@v1.56.3-0.20240311192827-d18acc5b51ed/pkg/timeutils/stopwatch.go:111 +0x44 github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe(0xc00045e2a0?) /home/firelizzard/go/pkg/mod/github.com/golangci/golangci-lint@v1.56.3-0.20240311192827-d18acc5b51ed/pkg/golinters/goanalysis/runner_action.go:111 +0x7a github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func2(0xc00353b5b0) /home/firelizzard/go/pkg/mod/github.com/golangci/golangci-lint@v1.56.3-0.20240311192827-d18acc5b51ed/pkg/golinters/goanalysis/runner_loadingpackage.go:80 +0xa8 created by github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze in goroutine 800 /home/firelizzard/go/pkg/mod/github.com/golangci/golangci-lint@v1.56.3-0.20240311192827-d18acc5b51ed/pkg/golinters/goanalysis/runner_loadingpackage.go:75 +0x205 WARN [runner] Can't run linter goanalysis_metalinter: goanalysis_metalinter: httpresponse: package "simulator" (isInitialPkg: true, needAnalyzeSource: true): runtime error: invalid memory address or nil pointer dereference INFO [runner] processing took 1.973µs with stages: max_same_issues: 474ns, skip_dirs: 237ns, nolint: 167ns, max_from_linter: 131ns, cgo: 105ns, autogenerated_exclude: 97ns, exclude-rules: 95ns, skip_files: 94ns, identifier_marker: 94ns, path_prettifier: 90ns, filename_unadjuster: 89ns, fixer: 37ns, diff: 31ns, severity-rules: 30ns, uniq_by_line: 30ns, sort_results: 30ns, exclude: 30ns, source_code: 30ns, path_shortener: 28ns, path_prefixer: 27ns, max_per_file_from_linter: 27ns INFO [runner] linters took 554.127017ms with stages: goanalysis_metalinter: 554.104557ms ERRO Running error: can't run linter goanalysis_metalinter goanalysis_metalinter: httpresponse: package "simulator" (isInitialPkg: true, needAnalyzeSource: true): runtime error: invalid memory address or nil pointer dereference INFO Memory: 12 samples, avg is 188.0MB, max is 536.2MB INFO Execution took 1.051656194s
Thank you, as a temporary fix, I will revert golang.org/x/tools
sadly we cannot revert easily... :cry:
It's related to this commit https://github.com/golang/tools/commit/c111c4dfa
I know where the bug is but I don't find a way to create a minimal reproducible example.
I submitted a bug report https://github.com/golang/go/issues/66259
@firelizzard18 I linked your branch.
Can you remove the plugin section of the .golangci.yml
inside this branch?
The problem is related to func ChainFromJSON(s *string) (*[32]byte, error) {
, the *[32]byte
produces the panic :thinking:
I found the problem -> https://github.com/golang/go/issues/66259#issuecomment-1990261780
I stripped down .golangci.yml
to the minimum needed to reproduce the issue.
Thanks for your work on tracing this to the root cause.
I created a minimal example with only 2 files (it was not fun to remove all your code file by file and line by line :smile:)
https://github.com/golang/go/issues/66259#issuecomment-1992617964
The feedback on the Go issue is sparse, the CL attached will fix the problem but we have to wait
Fixed by #4620
thanks @ldez
It would be nice to improve visibility into this. I have been chasing my tail for a while with an issue which ultimately stems from the fact that this package: github.com/awnumar/memcall
does not actually support Solaris and illumos. I was running into an issue where this package is actually a dependency of a dependency, and it was not clear to me that the failure was a result of the package not being buildable. The fix is quite straight-forward and I am going to try to get it upstreamed, but more to the point, the way I figured out what is going on is by running this instead of the normal golangci-lint run
with a saved config file:
$ golangci-lint run -E typecheck .
main.go:6:2: could not import github.com/awnumar/memcall (-: # github.com/awnumar/memcall
../../go/pkg/mod/github.com/szaydel/memcall@v1.0.0-test/memcall_unix.go:15:23: undefined: unix.MADV_DONTDUMP) (typecheck)
"github.com/awnumar/memcall"
^
The reason you are seeing szaydel
in the path is because I used a replace directive in the go.mod
file. It certainly would have been easier to debug this if I saw this message. Instead, what I was seeing is the following:
... snip ...
WARN [runner] Can't run linter goanalysis_metalinter: findcall: failed to load package memcall: could not load export data: no export data for "github.com/awnumar/memcall"
... snip ...
ERRO Running error: can't run linter goanalysis_metalinter
findcall: failed to load package memcall: could not load export data: no export data for "github.com/awnumar/memcall"
... snip ...
Thank you for the link @ldez. My main issue was that when I ran golangci-lint
the way it would normally run under CI, this was not visible. As soon as I isolated the problem with the help of -E typecheck
it became clear what is going on.
From this output, I could not tell what is going on:
WARN [runner] Can't run linter goanalysis_metalinter: findcall: failed to load package memcall: could not load export data: no export data for "github.com/awnumar/memcall"
-E typecheck
doesn't nothing (except if you are using a very old version of golangci-lint) because typecheck
can not be enabled or disabled because it's not a linter.
That's interesting. I am not running an old version of golangci-lint
. Perhaps this is just a matter of the configuration leading to the error being hidden, or the fact that in my dummy project this is a direct dependency as opposed to my bigger project where this is a dependency of a dependency?
$ golangci-lint version
golangci-lint has version 1.59.1 built with go1.22.3 from 1a55854a on 2024-06-09T18:08:33Z
The only effect is a kind of side effect: if you are using
disable-all
then -E
will override your enable
configuration to "enable" only typecheck
.Technically it's the same thing as disabling all the linters, so you will just have typecheck
.
EDIT: I said something wrong because -E
append (and not override) to the existing enable
configuration.
I guess I am still not sure what is going on. I am going to see if I can figure out why I am observing different outcomes. The best I can come-up with is the difference in package being a direct as opposed to an indirect dependency. Thank you for the feedback @ldez.
Welcome
Description of the problem
Pull the latest code and use make build. It cannot be exploded accordingly.
GoLang Version: 1.21.8 golangci-lint Version: latest master make build
Version of golangci-lint
Configuration
Go environment
Verbose output of running
A minimal reproducible example or link to a public repository
Validation