Skip to content

regression: S1029: interface conversion: interface {} is nil, not *buildir.IR #2868

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

Closed
4 tasks done
powerman opened this issue May 21, 2022 · 5 comments
Closed
4 tasks done
Labels
duplicate This issue or pull request already exists

Comments

@powerman
Copy link

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. (https://golangci-lint.run/usage/linters/)

Description of the problem

Versions 1.46.0 -1.46.2 are crashing on some generic code, 1.45.2 works okay.

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version v1.46.2 built from (unknown, mod sum: "h1:o90t/Xa6dhJbvy8Bz2RpzUXqrkigp19DLStMolTZbyo=") on (unknown)

Configuration file

$ cat .golangci.yml

Go environment

$ go version && go env
go version go1.18.2 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/powerman/.cache/go-build"
GOENV="/home/powerman/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/powerman/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/powerman/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18.2"
GCCGO="gccgo"
GOAMD64="v3"
AR="ar"
CC="x86_64-pc-linux-gnu-gcc"
CXX="x86_64-pc-linux-gnu-g++"
CGO_ENABLED="1"
GOMOD="/home/powerman/tmp/go/bug-golangci-lint-generic1/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build17493945=/tmp/go-build -gno-record-gcc-switches"

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
level=info msg="[config_reader] Config search paths: [./ /home/powerman/tmp/go/bug-golangci-lint-generic1 /home/powerman/tmp/go /home/powerman/tmp /home/powerman /home /]"
level=info msg="[lintersdb] Active 10 linters: [deadcode errcheck gosimple govet ineffassign staticcheck structcheck typecheck unused varcheck]"
level=info msg="[loader] Go packages loading at mode 575 (types_sizes|compiled_files|deps|files|exports_file|imports|name) took 28.278406ms"
level=info msg="[runner/filename_unadjuster] Pre-built 0 adjustments in 84.11µs"
level=info msg="[linters context/goanalysis] analyzers took 5.19672ms with top 10 stages: printf: 440.46µs, ctrlflow: 393.38µs, fact_deprecated: 347.26µs, SA5003: 241µs, loopclosure: 233.44µs, SA4030: 217.18µs, asmdecl: 155.49µs, SA4027: 153.23µs, structtag: 135.47µs, S1038: 105.22µs"
level=error msg="[runner] Panic: S1029: package \"main\" (isInitialPkg: true, needAnalyzeSource: true): interface conversion: interface {} is nil, not *buildir.IR: goroutine 813 [running]:\nruntime/debug.Stack()\n\t/usr/lib/go/src/runtime/debug/stack.go:24 +0x65\ngithub.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func1()\n\t/home/powerman/go/pkg/mod/github.com/golangci/[email protected]/pkg/golinters/goanalysis/runner_action.go:101 +0x155\npanic({0x14a44c0, 0xc00080f920})\n\t/usr/lib/go/src/runtime/panic.go:838 +0x207\nhonnef.co/go/tools/internal/sharedcheck.CheckRangeStringRunes(0xc00082d2b0)\n\t/home/powerman/go/pkg/mod/honnef.co/go/[email protected]/internal/sharedcheck/lint.go:24 +0x17b\nhonnef.co/go/tools/simple.CheckRangeStringRunes(0x1481860?)\n\t/home/powerman/go/pkg/mod/honnef.co/go/[email protected]/simple/lint.go:1630 +0x19\ngithub.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyze(0xc000c16990)\n\t/home/powerman/go/pkg/mod/github.com/golangci/[email protected]/pkg/golinters/goanalysis/runner_action.go:187 +0x9c4\ngithub.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func2()\n\t/home/powerman/go/pkg/mod/github.com/golangci/[email protected]/pkg/golinters/goanalysis/runner_action.go:105 +0x1d\ngithub.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0xc0011702d0, {0x15c7082, 0x5}, 0xc000f87748)\n\t/home/powerman/go/pkg/mod/github.com/golangci/[email protected]/pkg/timeutils/stopwatch.go:111 +0x4a\ngithub.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe(0x0?)\n\t/home/powerman/go/pkg/mod/github.com/golangci/[email protected]/pkg/golinters/goanalysis/runner_action.go:104 +0x85\ngithub.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func2(0xc000c16990)\n\t/home/powerman/go/pkg/mod/github.com/golangci/[email protected]/pkg/golinters/goanalysis/runner_loadingpackage.go:80 +0xb4\ncreated by github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze\n\t/home/powerman/go/pkg/mod/github.com/golangci/[email protected]/pkg/golinters/goanalysis/runner_loadingpackage.go:75 +0x1eb\n"
level=warning msg="[runner] Can't run linter goanalysis_metalinter: goanalysis_metalinter: S1029: package \"main\" (isInitialPkg: true, needAnalyzeSource: true): interface conversion: interface {} is nil, not *buildir.IR"
level=warning msg="[linters context] structcheck is disabled because of go1.18. You can track the evolution of the go1.18 support by following the https://github.com/golangci/golangci-lint/issues/2649."
level=info msg="[runner] processing took 2.53µs with stages: uniq_by_line: 610ns, max_same_issues: 380ns, nolint: 270ns, max_from_linter: 180ns, skip_dirs: 140ns, cgo: 120ns, autogenerated_exclude: 120ns, identifier_marker: 110ns, filename_unadjuster: 110ns, skip_files: 100ns, path_prettifier: 100ns, exclude-rules: 40ns, sort_results: 40ns, path_prefixer: 30ns, severity-rules: 30ns, source_code: 30ns, path_shortener: 30ns, diff: 30ns, exclude: 30ns, max_per_file_from_linter: 30ns"
level=info msg="[runner] linters took 5.621589ms with stages: goanalysis_metalinter: 5.590139ms, structcheck: 6.48µs"
level=error msg="Running error: 1 error occurred:\n\t* can't run linter goanalysis_metalinter: goanalysis_metalinter: S1029: package \"main\" (isInitialPkg: true, needAnalyzeSource: true): interface conversion: interface {} is nil, not *buildir.IR\n\n"
level=info msg="Memory: 2 samples, avg is 56.4MB, max is 56.5MB"
level=info msg="Execution took 37.829854ms"
exit status 3

Code example or link to a public repository

package main

import (
	"golang.org/x/exp/maps"
	"golang.org/x/exp/slices"
)

func check(filters map[int][]string) bool {
	want := map[int][]string{1: {"*"}}
	return maps.EqualFunc(filters, want, slices.Equal[string])
}
@powerman powerman added the bug Something isn't working label May 21, 2022
@powerman
Copy link
Author

Sometimes error on same code looks like this:

can't run linter goanalysis_metalinter: goanalysis_metalinter: buildir: package "main" (isInitialPkg: true, needAnalyzeSource: true): in <cut>: cannot convert golang.org/x/exp/slices.Equal (func[E comparable](s1 []E, s2 []E) bool) to func([]string, []string) bool

@powerman
Copy link
Author

Another code example, same issue.

package main

import "fmt"

// GoDrain runs Drain in a goroutine. Useful in defer.
func GoDrain[T <-chan E | chan E, E any](c T) {
	go Drain(c)
}

// Drain any channel.
func Drain[T <-chan E | chan E, E any](c T) {
	for range c {
	}
}

// UnexpectedMsg if you get any msg from this channel you will get panic.
func UnexpectedMsg[T <-chan E | chan E, E any](c T) {
	for msg := range c {
		panic(fmt.Sprintf("unexpected msg: %#+v", msg))
	}
}

@ldez
Copy link
Member

ldez commented May 21, 2022

Duplicate of #2859

@ldez ldez marked this as a duplicate of #2859 May 21, 2022
@powerman
Copy link
Author

Duplicate of #2859

Maybe. But it happens even with --enable-all --disable=staticcheck, so it's not because of staticheck itself.

@ldez
Copy link
Member

ldez commented May 21, 2022

staticcheck is a binary and a set of rules, those rules are grouped in "category": staticcheck, gosimple, stylecheck and unused.

S1029 is a rule from gosimple so it's related to staticheck.

@ldez ldez closed this as completed May 21, 2022
@ldez ldez added duplicate This issue or pull request already exists and removed bug Something isn't working labels May 21, 2022
@ldez ldez changed the title regression: goanalysis_metalinter: S1029: interface conversion: interface {} is nil, not *buildir.IR regression: S1029: interface conversion: interface {} is nil, not *buildir.IR May 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants