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

Do not do nil pointer dereference on MySQL init error. #168

Merged
merged 5 commits into from
May 9, 2024

Conversation

xaionaro
Copy link
Member

Before

[xaionaro@void contest]$ go run ./cmds/contest
[2023-06-16T18:30:56.169+01:00 I pluginregistry.go:65] Registering target manager csvfiletargetmanager
[2023-06-16T18:30:56.169+01:00 I pluginregistry.go:65] Registering target manager targetlist
[2023-06-16T18:30:56.169+01:00 I pluginregistry.go:78] Registering test fetcher literal
[2023-06-16T18:30:56.169+01:00 I pluginregistry.go:78] Registering test fetcher uri
[2023-06-16T18:30:56.169+01:00 I pluginregistry.go:91] Registering test step cmd
[2023-06-16T18:30:56.170+01:00 I pluginregistry.go:91] Registering test step cpucmd
[2023-06-16T18:30:56.170+01:00 I pluginregistry.go:91] Registering test step echo
[2023-06-16T18:30:56.170+01:00 I pluginregistry.go:91] Registering test step exec
[2023-06-16T18:30:56.170+01:00 I pluginregistry.go:91] Registering test step gathercmd
[2023-06-16T18:30:56.170+01:00 I pluginregistry.go:91] Registering test step randecho
[2023-06-16T18:30:56.170+01:00 I pluginregistry.go:91] Registering test step sleep
[2023-06-16T18:30:56.170+01:00 I pluginregistry.go:91] Registering test step sshcmd
[2023-06-16T18:30:56.170+01:00 I pluginregistry.go:115] Registering reporter noop
[2023-06-16T18:30:56.170+01:00 I pluginregistry.go:115] Registering reporter targetsuccess
[2023-06-16T18:30:56.170+01:00 I server.go:206] Using database URI for primary storage: contest:contest@tcp(localhost:3306)/contest?parseTime=true
[2023-06-16T18:30:56.171+01:00 F server.go:210] Could not initialize database: unable to contact database: dial tcp [::1]:3306: connect: connection refused
panic: runtime error: invalid memory address or nil pointer dereference
	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x8efa3a]

goroutine 1 [running]:
github.com/linuxboot/contest/cmds/contest/server.Main.func1()
	/home/xaionaro/go/src/github.com/linuxboot/contest/cmds/contest/server/server.go:196 +0x7a
panic({0xa11e00, 0xfb76b0})
	/home/xaionaro/.gimme/versions/go1.20.linux.amd64/src/runtime/panic.go:884 +0x213
github.com/linuxboot/contest/cmds/contest/server.Main(0xc000458240?, {0x7ffceadcfe35?, 0x3?}, {0xc000024050, 0x0, 0x0}, 0xc000458240)
	/home/xaionaro/go/src/github.com/linuxboot/contest/cmds/contest/server/server.go:215 +0x8c6
main.main()
	/home/xaionaro/go/src/github.com/linuxboot/contest/cmds/contest/main.go:69 +0x139
exit status 2

After

[xaionaro@void contest]$ go run ./cmds/contest
[2023-06-16T18:30:46.804+01:00 I pluginregistry.go:65] Registering target manager csvfiletargetmanager
[2023-06-16T18:30:46.805+01:00 I pluginregistry.go:65] Registering target manager targetlist
[2023-06-16T18:30:46.805+01:00 I pluginregistry.go:78] Registering test fetcher literal
[2023-06-16T18:30:46.805+01:00 I pluginregistry.go:78] Registering test fetcher uri
[2023-06-16T18:30:46.805+01:00 I pluginregistry.go:91] Registering test step cmd
[2023-06-16T18:30:46.805+01:00 I pluginregistry.go:91] Registering test step cpucmd
[2023-06-16T18:30:46.805+01:00 I pluginregistry.go:91] Registering test step echo
[2023-06-16T18:30:46.805+01:00 I pluginregistry.go:91] Registering test step exec
[2023-06-16T18:30:46.805+01:00 I pluginregistry.go:91] Registering test step gathercmd
[2023-06-16T18:30:46.805+01:00 I pluginregistry.go:91] Registering test step randecho
[2023-06-16T18:30:46.805+01:00 I pluginregistry.go:91] Registering test step sleep
[2023-06-16T18:30:46.805+01:00 I pluginregistry.go:91] Registering test step sshcmd
[2023-06-16T18:30:46.805+01:00 I pluginregistry.go:115] Registering reporter noop
[2023-06-16T18:30:46.805+01:00 I pluginregistry.go:115] Registering reporter targetsuccess
[2023-06-16T18:30:46.805+01:00 I server.go:209] Using database URI for primary storage: contest:contest@tcp(localhost:3306)/contest?parseTime=true
[2023-06-16T18:30:46.806+01:00 F server.go:213] Could not initialize database: unable to contact database: dial tcp [::1]:3306: connect: connection refused
exit status 1

@xaionaro xaionaro changed the title Bugfix/nil storage close Do not do nil pointer dereference on MySQL init error. Jun 16, 2023
@xaionaro xaionaro force-pushed the bugfix/nil_storage_close branch 2 times, most recently from 6efdf11 to 98f8552 Compare June 16, 2023 17:32
The error was actually in the logrus, so we added a fix in go-belt
to mitigate the error. And in contest we now pull the new version
of go-belt.

Signed-off-by: Dmitrii Okunev <xaionaro@meta.com>
@mimir-d
Copy link
Member

mimir-d commented May 9, 2024

this needs to be rebased on top of #173 for the CI fixes

@mimir-d mimir-d merged commit d1dd884 into develop May 9, 2024
5 checks passed
@mimir-d mimir-d deleted the bugfix/nil_storage_close branch May 9, 2024 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants