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

Check for nil before using struct #6238

Merged
merged 2 commits into from
May 29, 2020
Merged

Check for nil before using struct #6238

merged 2 commits into from
May 29, 2020

Conversation

systay
Copy link
Collaborator

@systay systay commented May 29, 2020

Fix for this problem:

I0529 01:54:58.175001    1272 logutil.go:31] log: http: panic serving 172.17.0.1:48142: runtime error: invalid memory address or nil pointer dereference
goroutine 26452 [running]:
net/http.(*conn).serve.func1(0xc0008aec80)
	/usr/local/go/src/net/http/server.go:1767 +0x139
panic(0x1e35d80, 0x3827060)
	/usr/local/go/src/runtime/panic.go:679 +0x1b2
vitess.io/vitess/go/vt/vttablet/tabletserver.txlogzHandler(0x25c8400, 0xc0005082a0, 0xc00010f800)
	/vt/src/vitess.io/vitess/go/vt/vttablet/tabletserver/txlogz.go:123 +0x368
net/http.HandlerFunc.ServeHTTP(0x22536f8, 0x25c8400, 0xc0005082a0, 0xc00010f800)
	/usr/local/go/src/net/http/server.go:2007 +0x44
net/http.(*ServeMux).ServeHTTP(0x3855320, 0x25c8400, 0xc0005082a0, 0xc00010f800)
	/usr/local/go/src/net/http/server.go:2387 +0x1bd
net/http.serverHandler.ServeHTTP(0xc0002321c0, 0x25c8400, 0xc0005082a0, 0xc00010f800)
	/usr/local/go/src/net/http/server.go:2802 +0xa4
net/http.(*conn).serve(0xc0008aec80, 0x25d4fc0, 0xc0009db980)
	/usr/local/go/src/net/http/server.go:1890 +0x875
created by net/http.(*Server).Serve
	/usr/local/go/src/net/http/server.go:2928 +0x384

Signed-off-by: Andres Taylor <andres@planetscale.com>
@systay systay requested a review from sougou as a code owner May 29, 2020 05:13
log.Errorf("txlogz: couldn't execute template: %v", err)
props := txc.txProps
// not all StatefulConnections contain transactions
if props != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wanna do early return?

Suggested change
if props != nil {
if props == nil {
continue

Signed-off-by: Andres Taylor <andres@planetscale.com>
Copy link
Member

@deepthi deepthi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
Can merge once CI passes. I suggest squashing the commits since they are both small.

@deepthi
Copy link
Member

deepthi commented May 29, 2020

If you don't mind, would you paste the reported error into the PR description so that future readers know what problem is being fixed?

@systay systay merged commit 41c356e into vitessio:master May 29, 2020
@deepthi deepthi added this to the v7.0 milestone Jul 17, 2020
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.

3 participants