-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
net/rpc: no way to get visibility into write errors (debugLog isn't exposed or changed) #71559
Comments
Related Issues
Related Discussions (Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.) |
As the package docs indicate, the package is frozen. I don't think any chance will be made here, sorry. |
@seankhliao would it make sense to move if that extends even to security issues, can if need be i can open another issue. |
We will still address bugs, but the fact that I sent https://go.dev/cl/646575 to move up the notice. Thanks for the suggestion. |
Change https://go.dev/cl/646575 mentions this issue: |
@ianlancetaylor would "errors returned when writing to the provided codec are silently dropped" be a bug? edit: my comment about bugs not getting fixed stems from the original justification @robpike had for freezing it
heavily implies bugs will not be fixed going forward |
Fair enough. |
Not sure what to take away from that- should I make a PR so it always logs (fix the bug, which is opposite @robpike's rationale for freezing it), open a proposal for a louder warning/notice that |
I've already sent a change to make it clearer that the package is frozen. I don't see why this is a vulnerability, so vulndb doesn't seem appropriate. I recommend that you copy the package into your source tree, and edit it as you see fit. It doesn't depend on any internal standard library APIs, so copying it should be straightforward. |
For #71559 Change-Id: I68b9518a26cab75789d596839267abab7997bc2c Reviewed-on: https://go-review.googlesource.com/c/go/+/646575 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Rob Pike <r@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Commit-Queue: Ian Lance Taylor <iant@google.com>
It turns out when `net/rpc` calls `WriteResponse`, it [**doesn't do anything with the error**](https://github.com/golang/go/blob/cb47156e90cac6b1030d747f1ccd433c00494dfc/src/net/rpc/server.go#L359-L362)! (it does correctly propagate errors when `WriteRequest` is called though) This means this codec needs to handle connection disposal, because there's no way for someone using `net/rpc` to find out about the error and handle it- we're in the twilight zone. Additionally, because `net/rpc` is frozen upstream, there is a lack of desire to fix even the logging aspect, let alone the underlying defect: golang/go#71559 The `WriteResponse` and `WriteRequest` methods both use the same underlying `write` method, so this fix took three commits- * adding the first test coverage to this package, to prove de-DRYing doesn't break anything * de-DRYing by inlining `write` into `WriteResponse` and `WriteRequest` * the actual fix, along with a test for it This puts an end to two years of "spooky behaviour at a distance" on our large and geographically distributed Nomad cluster. Fixes: hashicorp/nomad#23305
Go version
go version go1.23.1 darwin/arm64
Output of
go env
in your module/workspace:What did you do?
I was investigating this issue (I'm linking to a comment) hashicorp/yamux#143 (comment) that involved
net/rpc
.The core of the issue is a Write error getting returned from the related codec was never going anywhere. The documentation for
net/rpc.ServerCodec
hasWriteResponse
returning an error: https://pkg.go.dev/net/rpc#ServerCodecRequiring implementation of an interface to return an error implies that something is done with the error, and so I wanted to see the error that was getting returned. That's when I discovered that's controlled by
net/rpc.debugLog
. Unfortunately, that value is only ever read, and never written to.The Gob Codec does do logging of errors-
go/src/net/rpc/server.go
Line 413 in b07b20f
The jsonrpc Codec does not do logging of errors-
go/src/net/rpc/jsonrpc/server.go
Line 102 in b07b20f
What did you see happen?
Errors were silenced, and there's no way to enable
debugLog
w/o modifying and recompiling thenet/rpc
package.insert something tongue-in-cheek about proving a negative
What did you expect to see?
I expected a couple things
net/rpc
error logging that doesn't involve modifying the standard library and recompilingWriteResponse
when replying to anet/rpc
callnet/rpc
codecs in the Go standard library be internally consistent wrt logging of errorserror
in its log messages, butnet/rpc
just prefixes them withrpc:
)net/rpc
callsWriteResponse
on a codec and it returns an error, it should then callClose
. Based on this comment in the documentation, this should not cause consistency issues-Close can be called multiple times and must be idempotent.
The text was updated successfully, but these errors were encountered: