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

sqlclosecheck crashes when sql.Stmt is stored in global var #21

Open
TelpeNight opened this issue Mar 30, 2023 · 1 comment
Open

sqlclosecheck crashes when sql.Stmt is stored in global var #21

TelpeNight opened this issue Mar 30, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@TelpeNight
Copy link

TelpeNight commented Mar 30, 2023

sqlclosecheck doesn't work correctly in this case.
#20 - a concrete test case.

Maybe this approach of dealing with Stmt is not good, but we have some small go scripts which work in this way. So the crash prevents us to run check on the whole codebase.

The test output:

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

goroutine 349 [running]:
github.com/ryanrolds/sqlclosecheck/pkg/analyzer.getAction({0x1391d78?, 0xc006d63da0?}, {0xc0078d6880?, 0x2, 0x2})
	sqlclosecheck/pkg/analyzer/analyzer.go:250 +0x258
github.com/ryanrolds/sqlclosecheck/pkg/analyzer.checkClosed(0xc007ecd700?, {0xc0078d6880, 0x2, 0x2})
	sqlclosecheck/pkg/analyzer/analyzer.go:185 +0x85
github.com/ryanrolds/sqlclosecheck/pkg/analyzer.run(0xc00867e2d0)
	sqlclosecheck/pkg/analyzer/analyzer.go:77 +0x285
golang.org/x/tools/go/analysis/internal/checker.(*action).execOnce(0xc0086606e0)
	sqlclosecheck/vendor/golang.org/x/tools/go/analysis/internal/checker/checker.go:725 +0x9ec
sync.(*Once).doSlow(0x129d2e9?, 0xc00009e000?)
	/Users/nick/go/go1.20.2/src/sync/once.go:74 +0xc2
sync.(*Once).Do(...)
	/Users/nick/go/go1.20.2/src/sync/once.go:65
golang.org/x/tools/go/analysis/internal/checker.(*action).exec(0xc006053b78?)
	sqlclosecheck/vendor/golang.org/x/tools/go/analysis/internal/checker/checker.go:641 +0x3d
golang.org/x/tools/go/analysis/internal/checker.execAll.func1(0x0?)
	sqlclosecheck/vendor/golang.org/x/tools/go/analysis/internal/checker/checker.go:629 +0x25
created by golang.org/x/tools/go/analysis/internal/checker.execAll
	sqlclosecheck/vendor/golang.org/x/tools/go/analysis/internal/checker/checker.go:635 +0x165


Process finished with the exit code 1
@ryanrolds
Copy link
Owner

Thank you for raising this and for the test case. I will be looking at this more and potentially fixing it.

@ryanrolds ryanrolds added the bug Something isn't working label Aug 20, 2023
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

No branches or pull requests

2 participants