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 using sqlite and requesting a user by their nfc token #7

Closed
derconno opened this issue Aug 11, 2024 · 1 comment · Fixed by #8
Closed

Panic when using sqlite and requesting a user by their nfc token #7

derconno opened this issue Aug 11, 2024 · 1 comment · Fixed by #8
Assignees
Labels
bug Something isn't working

Comments

@derconno
Copy link
Collaborator

While working on Issue #5, I encountered the following panic:

=== RUN   TestGetUserForNFCToken
--- FAIL: TestGetUserForNFCToken (0.01s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x80 pc=0x55a10e]

goroutine 35 [running]:
testing.tRunner.func1.2({0x8d0040, 0xce28f0})
	/usr/lib/golang/src/testing/testing.go:1631 +0x24a
testing.tRunner.func1()
	/usr/lib/golang/src/testing/testing.go:1634 +0x377
panic({0x8d0040?, 0xce28f0?})
	/usr/lib/golang/src/runtime/panic.go:770 +0x132
database/sql.(*Rows).closemuRUnlockIfHeldByScan(0xd54340?)
	/usr/lib/golang/src/database/sql/sql.go:3366 +0xe
database/sql.(*Rows).Close(0x0)
	/usr/lib/golang/src/database/sql/sql.go:3393 +0x18
github.com/Port39/go-drink/users.GetUserForId({0x9e1600, 0xd54340}, {0xc00012e660?, 0xc00019dda8?}, 0xc000117380)
	/home/derconno/workspaces/goland/go-drink/users/user.go:101 +0x37a
github.com/Port39/go-drink/users.GetUserForNFCToken({0x9e1600, 0xd54340}, {0xc9b320?, 0xc00019df28?, 0x9264ef?}, 0xc000117380)
	/home/derconno/workspaces/goland/go-drink/users/user.go:139 +0x239
github.com/Port39/go-drink/users.TestGetUserForNFCToken(0xc000142820)
	/home/derconno/workspaces/goland/go-drink/users/users_test.go:129 +0x2cb
testing.tRunner(0xc000142820, 0x962fa8)
	/usr/lib/golang/src/testing/testing.go:1689 +0xfb
created by testing.(*T).Run in goroutine 1
	/usr/lib/golang/src/testing/testing.go:1742 +0x390


Process finished with the exit code 1

The fix should be to not defer closing the result in the function GetUserForNFCToken, as the sqlite driver has concurrency problems.

@derconno derconno self-assigned this Aug 11, 2024
@derconno derconno added the bug Something isn't working label Aug 11, 2024
@derconno
Copy link
Collaborator Author

the issue has been reported upstream: https://gitlab.com/cznic/sqlite/-/issues/189

@derconno derconno linked a pull request Aug 11, 2024 that will close this issue
derconno added a commit that referenced this issue Aug 11, 2024
…sting-a-user-by-their-nfc-token

closing rows before performing another query to fix issue #7
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.

1 participant