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

Fix nil pointer dereference #4886

Merged
merged 1 commit into from Aug 21, 2023
Merged

Fix nil pointer dereference #4886

merged 1 commit into from Aug 21, 2023

Conversation

fasmat
Copy link
Member

@fasmat fasmat commented Aug 21, 2023

Motivation

Latest release causes a nil pointer dereference error for some users:

2023-08-21T19:48:11.170+0800	INFO	grpc.Smesher	GRPC SmesherService.PostSetupStatus	{"module": "grpc"}
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x1 addr=0x0 pc=0x7ff6c6731597]

goroutine 27356 [running]:
github.com/spacemeshos/go-spacemesh/api/grpcserver.statusToPbStatus(...)
	D:/a/go-spacemesh/go-spacemesh/api/grpcserver/smesher_service.go:261
github.com/spacemeshos/go-spacemesh/api/grpcserver.SmesherService.PostSetupStatus({{0x7ff6c75ea7e8, 0xc0148d8510}, {0x7ff6c75dff30, 0xc008a7c800}, {0x7ff6c75e7370, 0xc000626540}, 0x3b9aca00, {{0xc0006b3008, 0x14}, 0x1c, ...}}, ...)
	D:/a/go-spacemesh/go-spacemesh/api/grpcserver/smesher_service.go:180 +0x97
github.com/spacemeshos/api/release/go/spacemesh/v1._SmesherService_PostSetupStatus_Handler.func1({0x7ff6c75def38, 0xc001ae2ea0}, {0x7ff6c6f7d200?, 0xc001ae2d50})
	C:/Users/runneradmin/go/pkg/mod/github.com/spacemeshos/api/release/go@v1.19.0/spacemesh/v1/smesher.pb.go:673 +0x78
github.com/grpc-ecosystem/go-grpc-middleware/logging/zap.UnaryServerInterceptor.func1({0x7ff6c75def38, 0xc001ae2db0}, {0x7ff6c6f7d200, 0xc001ae2d50}, 0xc000514ee0, 0xc003ad7800)
	C:/Users/runneradmin/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.4.0/logging/zap/server_interceptors.go:31 +0x115
google.golang.org/grpc.getChainUnaryHandler.func1({0x7ff6c75def38, 0xc001ae2db0}, {0x7ff6c6f7d200, 0xc001ae2d50})
	C:/Users/runneradmin/go/pkg/mod/google.golang.org/grpc@v1.57.0/server.go:1179 +0xb9
github.com/grpc-ecosystem/go-grpc-middleware/tags.UnaryServerInterceptor.func1({0x7ff6c75def38?, 0xc001ae2cf0?}, {0x7ff6c6f7d200, 0xc001ae2d50}, 0xc000514ee0, 0xc014a5d3c0)
	C:/Users/runneradmin/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.4.0/tags/interceptors.go:23 +0xa6
google.golang.org/grpc.chainUnaryInterceptors.func1({0x7ff6c75def38, 0xc001ae2cf0}, {0x7ff6c6f7d200, 0xc001ae2d50}, 0xc006235a58?, 0x7ff6c6ecd660?)
	C:/Users/runneradmin/go/pkg/mod/google.golang.org/grpc@v1.57.0/server.go:1170 +0x8f
github.com/spacemeshos/api/release/go/spacemesh/v1._SmesherService_PostSetupStatus_Handler({0x7ff6c70c1f00?, 0xc000278a20}, {0x7ff6c75def38, 0xc001ae2cf0}, 0xc0065aae70, 0xc005512820)
	C:/Users/runneradmin/go/pkg/mod/github.com/spacemeshos/api/release/go@v1.19.0/spacemesh/v1/smesher.pb.gopanic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x1 addr=0x0 pc=0x7ff6c6731597]

Changes

  • ensure ProviderID is initialized before dereferencing

Test Plan

  • new tests were added that failed the same way as reported by affected users and pass with the change.

TODO

  • Explain motivation or link existing issue(s)
  • Test changes and document test plan
  • Update documentation as needed

DevOps Notes

  • This PR does not require configuration changes (e.g., environment variables, GitHub secrets, VM resources)
  • This PR does not affect public APIs
  • This PR does not rely on a new version of external services (PoET, elasticsearch, etc.)
  • This PR does not make changes to log messages (which monitoring infrastructure may rely on)

@fasmat fasmat merged commit 4441f52 into v1.1 Aug 21, 2023
2 checks passed
@fasmat fasmat deleted the fix-nil-pointer branch August 21, 2023 12:40
@fasmat fasmat self-assigned this Aug 21, 2023
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.

None yet

1 participant