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: runtime error: invalid memory address or nil pointer dereference #20

Closed
SVilgelm opened this issue Feb 10, 2023 · 1 comment · Fixed by #21
Closed

panic: runtime error: invalid memory address or nil pointer dereference #20

SVilgelm opened this issue Feb 10, 2023 · 1 comment · Fixed by #21
Labels
bug Something isn't working

Comments

@SVilgelm
Copy link
Contributor

SVilgelm commented Feb 10, 2023

the linter panics on simple json.Marshal(nil) line.
I understand that this is the bad code, that should never exists, but we have it and the linter definitely should not panic on such code

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x10f8938]

goroutine 1275 [running]:
go/ast.(*Object).Pos(0x12914a0?)
	/go/go1.20/src/go/ast/scope.go:89 +0x18
github.com/junk1tm/musttag.run.func1({0x13371e8?, 0xc005cd8880})
	/musttag/musttag.go:163 +0x17e
golang.org/x/tools/go/ast/inspector.(*Inspector).Preorder(0xc00444c120, {0xc000501818?, 0x1?, 0xc000501870?}, 0xc000501828)
	/go/pkg/mod/golang.org/x/[email protected]/go/ast/inspector/inspector.go:77 +0x8b
github.com/junk1tm/musttag.run(0xc008a401a0, 0xc000501a38)
	/musttag/musttag.go:135 +0x137
github.com/junk1tm/musttag.New.func1(0x12991a0?)
	/musttag/musttag.go:104 +0x33c
golang.org/x/tools/go/analysis/internal/checker.(*action).execOnce(0xc001b75180)
	/go/pkg/mod/golang.org/x/[email protected]/go/analysis/internal/checker/checker.go:791 +0xe3d
sync.(*Once).doSlow(0x100523d?, 0x1257ca0?)
	/go/go1.20/src/sync/once.go:74 +0xc2
sync.(*Once).Do(...)
	/go/go1.20/src/sync/once.go:65
golang.org/x/tools/go/analysis/internal/checker.(*action).exec(0x103f085?)
	/go/pkg/mod/golang.org/x/[email protected]/go/analysis/internal/checker/checker.go:643 +0x3d
golang.org/x/tools/go/analysis/internal/checker.execAll.func1(0x0?)
	/go/pkg/mod/golang.org/x/[email protected]/go/analysis/internal/checker/checker.go:631 +0x25
created by golang.org/x/tools/go/analysis/internal/checker.execAll
	/go/pkg/mod/golang.org/x/[email protected]/go/analysis/internal/checker/checker.go:637 +0x165
SVilgelm added a commit to SVilgelm/musttag that referenced this issue Feb 10, 2023
fix go-simpler#20 for the panic on `json.Marshal(nil)` code
@tmzane tmzane added the bug Something isn't working label Feb 11, 2023
@tmzane
Copy link
Member

tmzane commented Feb 11, 2023

Definitely agree that it is bad behavior for a linter and should be fixed. Thank you for the report and the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants