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

Panic with slice to array pointer conversion #2430

Closed
4 tasks done
ronanh opened this issue Dec 22, 2021 · 2 comments
Closed
4 tasks done

Panic with slice to array pointer conversion #2430

ronanh opened this issue Dec 22, 2021 · 2 comments
Labels
duplicate This issue or pull request already exists

Comments

@ronanh
Copy link

ronanh commented Dec 22, 2021

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

I went into a panic with a piece of code that converts a slice into an array pointer (using an intermediate named type).

Note that the use of a named type is necessary to reproduce the bug.

Version of golangci-lint

golangci-lint has version v1.43.0 built from 861262b on 2021-11-03T12:17:18Z

Configuration file

Go environment

Verbose output of running

level=info msg="[config_reader] Config search paths: [./ /app / /root]"
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|imports|exports_file|files|name) took 53.279242ms"
level=info msg="[runner/filename_unadjuster] Pre-built 0 adjustments in 1.603387ms"
level=info msg="[linters context/goanalysis] analyzers took 5.559009ms with top 10 stages: ctrlflow: 1.925635ms, isgenerated: 1.081329ms, fact_deprecated: 599.653µs, printf: 513.793µs, ineffassign: 90.492µs, directives: 71.228µs, S1030: 58.82µs, sigchanyzer: 52.507µs, SA1012: 52.194µs, deadcode: 50.443µs"
level=error msg="[runner] Panic: S1029: package \"test_slicearraypconv\" (isInitialPkg: true, needAnalyzeSource: true): interface conversion: interface {} is nil, not *buildir.IR: goroutine 642 [running]:\nruntime/debug.Stack()\n\truntime/debug/stack.go:24 +0x65\ngithub.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func1()\n\tgithub.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:101 +0x155\npanic({0xe51860, 0xc000ce85d0})\n\truntime/panic.go:1038 +0x215\nhonnef.co/go/tools/internal/sharedcheck.CheckRangeStringRunes(0xc000ceb6c0)\n\thonnef.co/go/tools@v0.2.1/internal/sharedcheck/lint.go:23 +0x17b\nhonnef.co/go/tools/simple.CheckRangeStringRunes(0xe358c0)\n\thonnef.co/go/tools@v0.2.1/simple/lint.go:1512 +0x19\ngithub.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyze(0xc0006b4630)\n\tgithub.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:187 +0x9c4\ngithub.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func2()\n\tgithub.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:105 +0x1d\ngithub.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0xc00020d5e0, {0xf502c3, 0x5}, 0xc000712760)\n\tgithub.com/golangci/golangci-lint/pkg/timeutils/stopwatch.go:111 +0x4a\ngithub.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe(0xc0006b4630)\n\tgithub.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_action.go:104 +0x85\ngithub.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func2(0x0)\n\tgithub.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:80 +0x67\ncreated by github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze\n\tgithub.com/golangci/golangci-lint/pkg/golinters/goanalysis/runner_loadingpackage.go:75 +0x1fd\n"
level=warning msg="[runner] Can't run linter goanalysis_metalinter: goanalysis_metalinter: S1029: package \"test_slicearraypconv\" (isInitialPkg: true, needAnalyzeSource: true): interface conversion: interface {} is nil, not *buildir.IR"
level=info msg="[runner] processing took 2.946µs with stages: max_same_issues: 557ns, skip_dirs: 397ns, max_from_linter: 296ns, nolint: 272ns, uniq_by_line: 132ns, cgo: 131ns, autogenerated_exclude: 125ns, skip_files: 115ns, source_code: 115ns, identifier_marker: 110ns, path_prettifier: 110ns, exclude: 110ns, filename_unadjuster: 107ns, max_per_file_from_linter: 62ns, path_shortener: 54ns, diff: 54ns, sort_results: 54ns, exclude-rules: 49ns, severity-rules: 48ns, path_prefixer: 48ns"
level=info msg="[runner] linters took 13.132899ms with stages: goanalysis_metalinter: 13.092087ms"
level=info msg="File cache stats: 0 entries of total size 0B"
level=info msg="Memory: 2 samples, avg is 44.3MB, max is 44.3MB"
level=info msg="Execution took 78.573447ms"

Code example or link to a public repository

type iar2 [2]int

func main() {
        _ = (*iar2)([]int{1, 2})
}
@ronanh ronanh added the bug Something isn't working label Dec 22, 2021
@boring-cyborg
Copy link

boring-cyborg bot commented Dec 22, 2021

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

@ldez
Copy link
Member

ldez commented Dec 23, 2021

Duplicate of #2292
Fixed by #2370

It will be available in the next release.

@ldez ldez closed this as completed Dec 23, 2021
@ldez ldez added duplicate This issue or pull request already exists and removed bug Something isn't working labels Dec 23, 2021
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