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

goanalysis_metalinter panics on go1.20 netip package #3533

Closed
4 tasks done
aarongable opened this issue Feb 1, 2023 · 3 comments
Closed
4 tasks done

goanalysis_metalinter panics on go1.20 netip package #3533

aarongable opened this issue Feb 1, 2023 · 3 comments
Labels
duplicate This issue or pull request already exists

Comments

@aarongable
Copy link

aarongable commented Feb 1, 2023

Welcome

  • Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've included all information below (version, config, etc.).
  • Yes, I've tried with the standalone linter if available (e.g., gocritic, go vet, etc.). (https://golangci-lint.run/usage/linters/)

Description of the problem

Now that go1.20 has officially been released, I decided to come back and check on compatibility with golangci-lint again. I can reproduce the exact same error as @atc0005 reported a month and a half ago in #3420 (comment):

(Note that I am filing this as a separate bug, rather than continuing conversation there, because this is about goanalysis_metalinter whereas that bug was initially about the typecheck linter.)

$ cd /tmp
$ git clone https://github.com/letsencrypt/boulder
$ cd boulder
$ docker image pull golang:1.20rc3
$ docker container run -it --rm -v $PWD:$PWD -w $PWD golang:1.20rc3
$ go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.50.1
$ golangci-lint --version
$ golangci-lint run ./...

If I instead install golangci-lint at master, I get the same result:

$ go install github.com/golangci/golangci-lint/cmd/golangci-lint@master
$ golangci-lint --version
$ golangci-lint run ./...

Output is given below in the "Verbose output of running" section.

In both cases, the salient error text is:

ERRO Running error: 1 error occurred:
* can't run linter goanalysis_metalinter: goanalysis_metalinter: buildir: package "netip" (isInitialPkg: false, needAnalyzeSource: true): in net/netip.AddrFromSlice: cannot convert Load <[]byte> t0 ([]byte) to [4]byte

This appears to be the same issue as was addressed by dominikh/go-tools#1335 for that repo, but golangci-lint doesn't appear to have a dependency on that repo so I don't believe that fix has any impact on this project's behavior.

Are there any updates on what needs to change to avoid this issue?

Version of golangci-lint

Both v1.50.1 and tip-of-master exhibit this behavior:

$ golangci-lint --version
golangci-lint has version v1.50.1 built from (unknown, mod sum: "h1:C829clMcZXEORakZlwpk7M4iDw2XiwxxKaG504SZ9zY=") on (unknown)
$ golangci-lint --version
golangci-lint has version v1.50.2-0.20230130214903-abe878d80d6a built from (unknown, mod sum: "h1:g6FiSxLZmcccJGjFUdRjykX5gqmc0ZJm0SzgXhkSC1Y=") on (unknown)

Configuration file

$ cat .golangci.yml
linters:
  disable-all: true
  enable:
    - gofmt
    - gosec
    - gosimple
    - govet
    - ineffassign
    - misspell
    - staticcheck
    - stylecheck
    - typecheck
    - unconvert
    - unparam
    - unused
    # TODO(#6202): Re-enable 'wastedassign' linter
linters-settings:
  errcheck:
    ignore: fmt:[FS]?[Pp]rint*,io:Write,os:Remove,net/http:Write,github.com/miekg/dns:WriteMsg,net:Write,encoding/binary:Write
  gosimple:
    # S1029: Range over the string directly
    checks: ["all", "-S1029"]
  govet:
    settings:
      printf:
        funcs:
          - (github.com/letsencrypt/boulder/log.Logger).Errf
          - (github.com/letsencrypt/boulder/log.Logger).Warningf
          - (github.com/letsencrypt/boulder/log.Logger).Infof
          - (github.com/letsencrypt/boulder/log.Logger).Debugf
          - (github.com/letsencrypt/boulder/log.Logger).AuditInfof
          - (github.com/letsencrypt/boulder/log.Logger).AuditErrf
          - (github.com/letsencrypt/boulder/ocsp/responder).SampledError
          - (github.com/letsencrypt/boulder/web.RequestEvent).AddError
  staticcheck:
    # SA1019: Using a deprecated function, variable, constant or field
    # SA6003: Converting a string to a slice of runes before ranging over it
    checks: ["all", "-SA1019", "-SA6003"]
  stylecheck:
    # ST1003: Poorly chosen identifier
    # ST1005: Incorrectly formatted error string
    checks: ["all", "-ST1003", "-ST1005"]
  gosec:
    excludes:
      # TODO: Identify, fix, and remove violations of most of these rules
      - G101  # Potential hardcoded credentials
      - G102  # Binds to all network interfaces
      - G107  # Potential HTTP request made with variable url
      - G201  # SQL string formatting
      - G202  # SQL string concatenation
      - G306  # Expect WriteFile permissions to be 0600 or less
      - G401  # Use of weak cryptographic primitive
      - G402  # TLS InsecureSkipVerify set true.
      - G403  # RSA keys should be at least 2048 bits
      - G404  # Use of weak random number generator (math/rand instead of crypto/rand)
      - G501  # Blacklisted import `crypto/md5`: weak cryptographic primitive
      - G505  # Blacklisted import `crypto/sha1`: weak cryptographic primitive```

Go environment

$ go version && go env
go version go1.20rc3 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.20rc3"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/tmp/boulder/go.mod"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2258926050=/tmp/go-build -gno-record-gcc-switches"

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /tmp/boulder /tmp / /root]
INFO [config_reader] Used config file .golangci.yml
INFO [lintersdb] Active 12 linters: [gofmt gosec gosimple govet ineffassign misspell staticcheck stylecheck typecheck unconvert unparam unused]
INFO [loader] Go packages loading at mode 575 (name|types_sizes|compiled_files|imports|files|deps|exports_file) took 536.325148ms
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 22.428171ms
INFO [linters_context/goanalysis] analyzers took 3m5.835061677s with top 10 stages: buildssa: 19.975353158s, buildir: 10.806634829s, typedness: 4.464724653s, SA5012: 4.034637695s, unparam: 4.013279812s, nilness: 3.810260371s, fact_purity: 3.771863708s, gosec: 3.185616042s, unconvert: 3.026253891s, inspect: 2.723859399s
ERRO [runner] Panic: buildir: package "netip" (isInitialPkg: false, needAnalyzeSource: true): in net/netip.AddrFromSlice: cannot convert Load <[]byte> t0 ([]byte) to [4]byte: goroutine 8802 [running]:
runtime/debug.Stack()
	/usr/local/go/src/runtime/debug/stack.go:24 +0x65
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func1()
	/go/pkg/mod/github.com/golangci/golangci-lint@v1.50.2-0.20230130214903-abe878d80d6a/pkg/golinters/goanalysis/runner_action.go:102 +0x155
panic({0x1512ee0, 0xc0023f3bb0})
	/usr/local/go/src/runtime/panic.go:884 +0x213
honnef.co/go/tools/go/ir.emitConv(0xc004158000, {0x19530c8, 0xc0026dd6e0}, {0x1946510?, 0xc00ad50948}, {0x1945bd8, 0xc006f77180})
	/go/pkg/mod/honnef.co/go/tools@v0.3.3/go/ir/emit.go:293 +0xd29
honnef.co/go/tools/go/ir.(*builder).expr0(0xc00b8e3a28, 0xc004158000, {0x19498d0?, 0xc006f77180?}, {0x7, {0x1946510, 0xc00ad50948}, {0x0, 0x0}})
	/go/pkg/mod/honnef.co/go/tools@v0.3.3/go/ir/builder.go:610 +0x5d7
honnef.co/go/tools/go/ir.(*builder).expr(0x19466a0?, 0xc004158000, {0x19498d0, 0xc006f77180})
	/go/pkg/mod/honnef.co/go/tools@v0.3.3/go/ir/builder.go:566 +0x1fa
honnef.co/go/tools/go/ir.(*builder).emitCallArgs(0x19466a0?, 0xc004158000, 0xc00a9df100, 0xc006f771c0, {0x0?, 0x0, 0x8be0a7?})
	/go/pkg/mod/honnef.co/go/tools@v0.3.3/go/ir/builder.go:975 +0x135
honnef.co/go/tools/go/ir.(*builder).setCall(0x157cb60?, 0xc004158000, 0xc006f771c0, 0xc0026011c8)
	/go/pkg/mod/honnef.co/go/tools@v0.3.3/go/ir/builder.go:1037 +0x8e
honnef.co/go/tools/go/ir.(*builder).expr0(0xc00b8e3a28, 0xc004158000, {0x19498d0?, 0xc006f771c0?}, {0x7, {0x1946600, 0xc00a9fc000}, {0x0, 0x0}})
	/go/pkg/mod/honnef.co/go/tools@v0.3.3/go/ir/builder.go:623 +0x218e
honnef.co/go/tools/go/ir.(*builder).expr(0xc00b8e2e78?, 0xc004158000, {0x19498d0, 0xc006f771c0})
	/go/pkg/mod/honnef.co/go/tools@v0.3.3/go/ir/builder.go:566 +0x1fa
honnef.co/go/tools/go/ir.(*builder).stmt(0xc004158000?, 0xc004158000, {0x1949e10?, 0xc00a9831e0?})
	/go/pkg/mod/honnef.co/go/tools@v0.3.3/go/ir/builder.go:2291 +0x194c
honnef.co/go/tools/go/ir.(*builder).stmtList(...)
	/go/pkg/mod/honnef.co/go/tools@v0.3.3/go/ir/builder.go:855
honnef.co/go/tools/go/ir.(*builder).switchStmt(0xc00b8e3308?, 0xc004158000, 0xc0098069c0, 0x0)
	/go/pkg/mod/honnef.co/go/tools@v0.3.3/go/ir/builder.go:1366 +0x19a5
honnef.co/go/tools/go/ir.(*builder).stmt(0x20?, 0xc004158000, {0x1949f60?, 0xc0098069c0?})
	/go/pkg/mod/honnef.co/go/tools@v0.3.3/go/ir/builder.go:2365 +0x121c
honnef.co/go/tools/go/ir.(*builder).stmtList(0x8c4a25?, 0xc00b8e34f8?, {0xc00a9833a0?, 0x2, 0x8c6630?})
	/go/pkg/mod/honnef.co/go/tools@v0.3.3/go/ir/builder.go:855 +0x45
honnef.co/go/tools/go/ir.(*builder).stmt(0xc004158000?, 0xc004158000, {0x1949870?, 0xc0098069f0?})
	/go/pkg/mod/honnef.co/go/tools@v0.3.3/go/ir/builder.go:2338 +0x9b9
honnef.co/go/tools/go/ir.(*builder).buildFunction(0xc00b8e3a28, 0xc004158000)
	/go/pkg/mod/honnef.co/go/tools@v0.3.3/go/ir/builder.go:2450 +0x3d7
honnef.co/go/tools/go/ir.(*builder).buildFuncDecl(0x0?, 0xc007f30b40, 0xc009806a20)
	/go/pkg/mod/honnef.co/go/tools@v0.3.3/go/ir/builder.go:2488 +0x19b
honnef.co/go/tools/go/ir.(*Package).build(0xc007f30b40)
	/go/pkg/mod/honnef.co/go/tools@v0.3.3/go/ir/builder.go:2594 +0xc16
sync.(*Once).doSlow(0xc00877f340?, 0xc00a9d6a50?)
	/usr/local/go/src/sync/once.go:74 +0xc2
sync.(*Once).Do(...)
	/usr/local/go/src/sync/once.go:65
honnef.co/go/tools/go/ir.(*Package).Build(...)
	/go/pkg/mod/honnef.co/go/tools@v0.3.3/go/ir/builder.go:2512
honnef.co/go/tools/internal/passes/buildir.run(0xc00eef63c0)
	/go/pkg/mod/honnef.co/go/tools@v0.3.3/internal/passes/buildir/buildir.go:86 +0x368
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyze(0xc0039dc920)
	/go/pkg/mod/github.com/golangci/golangci-lint@v1.50.2-0.20230130214903-abe878d80d6a/pkg/golinters/goanalysis/runner_action.go:188 +0x9df
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func2()
	/go/pkg/mod/github.com/golangci/golangci-lint@v1.50.2-0.20230130214903-abe878d80d6a/pkg/golinters/goanalysis/runner_action.go:106 +0x1d
github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0xc00191f310, {0x16e0205, 0x7}, 0xc003f41f48)
	/go/pkg/mod/github.com/golangci/golangci-lint@v1.50.2-0.20230130214903-abe878d80d6a/pkg/timeutils/stopwatch.go:111 +0x4a
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe(0xc001d387e0?)
	/go/pkg/mod/github.com/golangci/golangci-lint@v1.50.2-0.20230130214903-abe878d80d6a/pkg/golinters/goanalysis/runner_action.go:105 +0x85
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func2(0xc0039dc920)
	/go/pkg/mod/github.com/golangci/golangci-lint@v1.50.2-0.20230130214903-abe878d80d6a/pkg/golinters/goanalysis/runner_loadingpackage.go:80 +0xb4
created by github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze
	/go/pkg/mod/github.com/golangci/golangci-lint@v1.50.2-0.20230130214903-abe878d80d6a/pkg/golinters/goanalysis/runner_loadingpackage.go:75 +0x1eb
WARN [runner] Can't run linter goanalysis_metalinter: goanalysis_metalinter: buildir: package "netip" (isInitialPkg: false, needAnalyzeSource: true): in net/netip.AddrFromSlice: cannot convert Load <[]byte> t0 ([]byte) to [4]byte
INFO [runner] processing took 3.308µs with stages: skip_dirs: 671ns, max_same_issues: 481ns, nolint: 271ns, max_per_file_from_linter: 240ns, cgo: 240ns, path_prettifier: 190ns, max_from_linter: 170ns, autogenerated_exclude: 150ns, source_code: 141ns, identifier_marker: 131ns, exclude-rules: 131ns, filename_unadjuster: 130ns, skip_files: 121ns, sort_results: 40ns, path_prefixer: 40ns, path_shortener: 40ns, severity-rules: 31ns, diff: 30ns, uniq_by_line: 30ns, exclude: 30ns
INFO [runner] linters took 4.024094204s with stages: goanalysis_metalinter: 4.024049079s
ERRO Running error: 1 error occurred:
	* can't run linter goanalysis_metalinter: goanalysis_metalinter: buildir: package "netip" (isInitialPkg: false, needAnalyzeSource: true): in net/netip.AddrFromSlice: cannot convert Load <[]byte> t0 ([]byte) to [4]byte

INFO Memory: 47 samples, avg is 1458.3MB, max is 6379.2MB
INFO Execution took 4.588094633s

Code example or link to a public repository

$ cd /tmp
$ git clone https://github.com/letsencrypt/boulder
$ cd boulder
$ docker image pull golang:1.20rc3
$ docker container run -it --rm -v $PWD:$PWD -w $PWD golang:1.20rc3
$ go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.50.1
$ golangci-lint --version
$ golangci-lint run ./...
@aarongable aarongable added the bug Something isn't working label Feb 1, 2023
@boring-cyborg
Copy link

boring-cyborg bot commented Feb 1, 2023

Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.

@aarongable
Copy link
Author

Ah, I see that golangci-lint actually does depend on dominikh/go-tools; I didn't realize that that repo is imported as honnef.co/go/tools.

It looks like the dominikh/go-tools#1335 fix has not yet been included in a tagged release from that repo: that fix landed in Dec 2022, but the last release v0.3.3 was cut in July 2022.

Perhaps the fix here is

  1. Get dominikh/go-tools to cut a new release
  2. Get golangci-lint to update its dependency on honnef.co/go/tools to the new release
  3. Cut a new release of golangci-lint

@ldez
Copy link
Member

ldez commented Feb 2, 2023

Duplicate of #3470
Please follow the PR #3414

@ldez ldez closed this as completed Feb 2, 2023
@ldez ldez mentioned this issue Feb 2, 2023
4 tasks
@ldez ldez added duplicate This issue or pull request already exists and removed bug Something isn't working labels Feb 2, 2023
@ldez ldez mentioned this issue Feb 2, 2023
4 tasks
@golangci golangci locked and limited conversation to collaborators Feb 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants