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

net/rpc or encoding/gob: Confusing behavior, deadlock or hang with what looks like valid code #8173

Closed
gopherbot opened this issue Jun 8, 2014 · 7 comments
Milestone

Comments

@gopherbot
Copy link

This was brought up by jgr on IRC. I can't come up with an explanation for this
behavior. Apologies if there's a mistake in the code.

This code: http://play.golang.org/p/U4elciYqmL
triggers the deadlock detector on playground, hangs on Linux (go tip 5439c77d4acb).
Exporting "msg" as "Msg" makes it work. `type Reply struct{}` makes
it work.

I don't see how different message contents would trigger deadlock/hang. I expected to
just see a "main.Reply{}" output for the non-exported case.
@gopherbot
Copy link
Author

Comment 1:

Wessie on IRC pointer out that net/rpc ignores errors from codec.WriteResponse.
http://golang.org/src/pkg/net/rpc/server.go#L360
http://play.golang.org/p/D1sd-llvdm
So perhaps this is a case of gob refusing to write anything, while the receiver is
expecting to see something, and nobody catching that error.

@gopherbot
Copy link
Author

Comment 2:

*pointed out

@gopherbot
Copy link
Author

Comment 3:

This is probably a duplicate of https://golang.org/issue/7689

@gopherbot
Copy link
Author

Comment 4:

Just to say this more explicitly, it looks the like the next async net/rpc response
arriving will be decoded as the body of the of the previous one, as the sending send did
not send any data. This will lead to Bad Things(tm).

@ianlancetaylor
Copy link
Contributor

Comment 5:

Labels changed: added repo-main, release-go1.4.

@robpike
Copy link
Contributor

robpike commented Oct 3, 2014

Comment 6:

It now gives:
2014/10/03 14:55:09 rpc: gob error encoding body: gob: type main.Reply has no exported
fields
panic: reading body EOF
Nice enough I might use it as a test for net/rpc.

Status changed to Duplicate.

Merged into issue #7689.

@gopherbot
Copy link
Author

Comment 7:

CL https://golang.org/cl/151370043 mentions this issue.

@rsc rsc added this to the Go1.4 milestone Apr 14, 2015
@rsc rsc removed the release-go1.4 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
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

4 participants