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 when analyzing package #972

Closed
dominikh opened this issue Apr 25, 2021 · 1 comment
Closed

Panic when analyzing package #972

dominikh opened this issue Apr 25, 2021 · 1 comment
Labels

Comments

@dominikh
Copy link
Owner

git clone https://github.com/IBM/go-sdk-core/
cd go-sdk-core/v5
git checkout mdk/empty-body # this is commit 18e9a9b1a12c0418509cd8db49746869b5fe1f46 at time of writing
GOOS=linux GOARCH=amd64 staticcheck -tags=all ./...
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x747415]

goroutine 643 [running]:
honnef.co/go/tools/analysis/report.getRange(0x7f7fb8331380, 0xc0010e2c60, 0xc001d7ab00, 0xc003169bf8, 0xc000790000)
	/home/dominikh/prj/src/honnef.co/go/tools/analysis/report/report.go:136 +0xf5
honnef.co/go/tools/analysis/report.Related.func1(0xc001d7ab00)
	/home/dominikh/prj/src/honnef.co/go/tools/analysis/report/report.go:47 +0x56
honnef.co/go/tools/analysis/report.Report(0xc000ded450, 0x9f4d00, 0xc0035a5ab0, 0xc002b3e320, 0x1d, 0xc003169d68, 0x1, 0x1)
	/home/dominikh/prj/src/honnef.co/go/tools/analysis/report/report.go:150 +0x6d
honnef.co/go/tools/staticcheck.CheckTypedNilInterface(0xc000ded450, 0x145e6683, 0xc5ca60, 0xc000ded3e8, 0x0)
	/home/dominikh/prj/src/honnef.co/go/tools/staticcheck/lint.go:4420 +0xb0d
honnef.co/go/tools/lintcmd/runner.(*analyzerRunner).do(0xc002093fb0, 0xa00f18, 0xc00208e320, 0x0, 0x0)
	/home/dominikh/prj/src/honnef.co/go/tools/lintcmd/runner/runner.go:938 +0x61b
honnef.co/go/tools/lintcmd/runner.genericHandle(0xa00f18, 0xc00208e320, 0xa00f18, 0xc0018f6320, 0xc0009e9c20, 0xc00030a0b8, 0xc00204cb10)
	/home/dominikh/prj/src/honnef.co/go/tools/lintcmd/runner/runner.go:763 +0x196
created by honnef.co/go/tools/lintcmd/runner.(*subrunner).runAnalyzers
	/home/dominikh/prj/src/honnef.co/go/tools/lintcmd/runner/runner.go:1004 +0x5ca
@dominikh
Copy link
Owner Author

Basic reproduction case:

package pkg

func fn() {
	var x interface{} = (map[string]int)(nil)
	_ = x == nil
}

dominikh added a commit that referenced this issue Apr 25, 2021
dominikh added a commit that referenced this issue May 1, 2021
Some IR values do not have a valid Source, most prominently constants.
Don't panic when we can avoid it: when trying to emit related
information, it makes more sense to drop the related information on
the floor than to panic. We still panic for the toplevel diagnostic,
because it makes no sense to print a diagnostic for an unknown
location. It is an explicit panic now, however, so we get a more
helpful message.

Closes gh-972
dominikh added a commit that referenced this issue May 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant