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

client: fix nil dereference when closing conns #514

Merged
merged 2 commits into from
May 31, 2022

Conversation

youjiali1995
Copy link
Contributor

Signed-off-by: youjiali1995 [email protected]

Introduced by #464. Connections can be nil if fails to connect some stores.

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

goroutine 47779631 [running]:
google.golang.org/grpc.(*ClientConn).Close(0x0)
	/go/pkg/mod/google.golang.org/[email protected]/clientconn.go:1059 +0x4b
github.com/tikv/client-go/v2/internal/client.(*connArray).Close(0xc326b88140)
	/go/pkg/mod/github.com/tikv/client-go/[email protected]/internal/client/client.go:242 +0x56
github.com/tikv/client-go/v2/internal/client.(*connArray).Init(0xc326b88140, {0xc001cd8978, 0x12}, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, {0x0, ...}}, ...)
	/go/pkg/mod/github.com/tikv/client-go/[email protected]/internal/client/client.go:202 +0xee6

Copy link
Collaborator

@sticnarf sticnarf left a comment

Choose a reason for hiding this comment

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

In which case may c be nil? Does it mean DialContext may return nil, nil?

@youjiali1995
Copy link
Contributor Author

In which case may c be nil? Does it mean DialContext may return nil, nil?

No. As long as DialContext returns error, c will be nil.

@sticnarf
Copy link
Collaborator

In which case may c be nil? Does it mean DialContext may return nil, nil?

No. As long as DialContext returns error, c will be nil.

I misread the code. I see.

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