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 dereference getPortStats gRPC message pointer on error #359

Merged
merged 3 commits into from Nov 16, 2021

Conversation

pudelkoM
Copy link
Member

@pudelkoM pudelkoM commented Nov 9, 2021

Currently pfcpagent will crash when the getPortStats gRPC call fails for any reason, because we dereference a nil pointer to the response message.

From the docs:

If the call doesn’t return an error, then we can read the response information from the server from the first return value.

https://grpc.io/docs/languages/go/basics/#calling-service-methods

Logs:

time="2021-11-06T17:53:03Z" level=info msg="Error calling get_summary on module access_measure rpc error: code = Unavailable desc = error reading from server: EOF" func="main.(*bess).measure" file="/pfcpiface/bess.go:219"
time="2021-11-06T17:53:03Z" level=info msg="Error calling get_summary on module core_measure rpc error: code = Unavailable desc = connection closed before server preface received" func="main.(*bess).measure" file="/pfcpiface/bess.go:219"
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x99f567]

goroutine 496605 [running]:
main.(*bess).getPortStats(0xc000340050, {0xc0001b9798, 0x6})
	/pfcpiface/bess.go:242 +0x147
main.(*bess).portStats.func1({0xb5430e, 0x4}, {0xc0001b9798, 0x4})
	/pfcpiface/bess.go:279 +0x10d
main.(*bess).portStats(0xc000952f20, 0xc00032c2a0, 0x861f3f)
	/pfcpiface/bess.go:294 +0x69
main.(*upfCollector).portStats(...)
	/pfcpiface/telemetry.go:117
main.(*upfCollector).Collect(0xc00032c2a0, 0xc000952f60)
	/pfcpiface/telemetry.go:112 +0x65
github.com/prometheus/client_golang/prometheus.(*Registry).Gather.func1()

@krsna1729 krsna1729 merged commit 78c4385 into master Nov 16, 2021
@krsna1729 krsna1729 deleted the get-port-stats-nil-pointer-deref branch November 16, 2021 06:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants