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 a handler returns an error that wraps an error that has gRPC status OK #6373

Closed
atollena opened this issue Jun 15, 2023 · 3 comments
Assignees

Comments

@atollena
Copy link
Collaborator

atollena commented Jun 15, 2023

What version of gRPC are you using?

1.55+. 1.54.1 is not affected because this most likely was introduced by https://github.com/grpc/grpc-go/pull/6031/files.

What version of Go are you using (go version)?

1.20.4

What operating system (Linux, Windows, …) and version?

Linux

What did you do?

We have services that return an error that wraps an error that have a grpc status code OK. When returns, gRPC panics:

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=0x2 addr=0x38 pc=0x100b36388]

goroutine 35 [running]:
testing.tRunner.func1.2({0x100d7be20, 0x10115cb60})
	/opt/homebrew/Cellar/go/1.20.4/libexec/src/testing/testing.go:1526 +0x1c8
testing.tRunner.func1()
	/opt/homebrew/Cellar/go/1.20.4/libexec/src/testing/testing.go:1529 +0x384
panic({0x100d7be20, 0x10115cb60})
	/opt/homebrew/Cellar/go/1.20.4/libexec/src/runtime/panic.go:884 +0x204
google.golang.org/grpc/status.FromError({0x100e1c2c8, 0x140001617c0})
	/Users/antoine.tollenaere/Dropbox/workspace/grpc-go/status/status.go:100 +0xd8
google.golang.org/grpc/status.s.TestFromErrorImplementsInterfaceReturnsNilWrapped({{}}, 0x1400011d380)
	/Users/antoine.tollenaere/Dropbox/workspace/grpc-go/status/status_test.go:199 +0x58
google.golang.org/grpc/internal/grpctest.RunSubTests.func1(0x1400011d380)
	/Users/antoine.tollenaere/Dropbox/workspace/grpc-go/internal/grpctest/grpctest.go:109 +0xbc
testing.tRunner(0x1400011d380, 0x140001616e0)
	/opt/homebrew/Cellar/go/1.20.4/libexec/src/testing/testing.go:1576 +0x10c
created by testing.(*T).Run
	/opt/homebrew/Cellar/go/1.20.4/libexec/src/testing/testing.go:1629 +0x368

What did you expect to see?

Not sure what the right behaviour is in that case. We could simply return OK, like we do for errors that directly have status OK. But a better behavior may be to return status code unknown.

What did you see instead?

Panic.

@atollena
Copy link
Collaborator Author

atollena commented Jun 15, 2023

cc @dfawley I have attached a branch with a test that demonstrate the behavior and a potential fix: #6374

We have run into this issue in one of our production service. Clearly wrapping an error with status OK seems wrong, but gRPC should probably better defend against that.

@atollena
Copy link
Collaborator Author

We were able to track down the error with GRPCStatus() that returns nil. It's here:

https://github.com/googleapis/google-cloud-go/blob/4eb8a58b1ca80239d046e0b759a292e24e85a772/internal/retry.go#L80-L85

If the wrapped error is not a gRPC error, the status.FromError returns (_, false) and GRPCStatus() returns nil.

(credit to @ella-chao)

@atollena
Copy link
Collaborator Author

atollena commented Jul 7, 2023

Fixed in #6374 present in Release 1.56.2 and Release 1.55.1.

@atollena atollena closed this as completed Jul 7, 2023
pwschuurman added a commit to pwschuurman/gcp-compute-persistent-disk-csi-driver that referenced this issue Sep 14, 2023
pwschuurman added a commit to pwschuurman/gcp-compute-persistent-disk-csi-driver that referenced this issue Sep 14, 2023
k8s-ci-robot added a commit to kubernetes-sigs/gcp-compute-persistent-disk-csi-driver that referenced this issue Sep 14, 2023
Upgrade google.golang.org/grpc from v1.55.0 -> v1.55.1 to address grpc/grpc-go#6373
pwschuurman added a commit to pwschuurman/gcp-compute-persistent-disk-csi-driver that referenced this issue Sep 15, 2023
pwschuurman added a commit to pwschuurman/gcp-compute-persistent-disk-csi-driver that referenced this issue Sep 15, 2023
k8s-ci-robot added a commit to kubernetes-sigs/gcp-compute-persistent-disk-csi-driver that referenced this issue Sep 20, 2023
Upgrade google.golang.org/grpc from v1.55.0 -> v1.55.1 to address grpc/grpc-go#6373
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant