Skip to content

Panic with slice to array pointer conversion #2430

Closed
@ronanh

Description

@ronanh

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/[email protected]/internal/sharedcheck/lint.go:23 +0x17b\nhonnef.co/go/tools/simple.CheckRangeStringRunes(0xe358c0)\n\thonnef.co/go/[email protected]/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})
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions