Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Possible deadlock when receive loops on both sides of an unbuffered connection try to send. #190

Closed
zenhack opened this issue Nov 19, 2021 · 2 comments · Fixed by #224
Closed
Labels
Milestone

Comments

@zenhack
Copy link
Contributor

zenhack commented Nov 19, 2021

While debugging #189, @lthibault and I realized there is another possible deadlock bug which was not triggered by his test program, but which is theoretically possible:

If two return messages are in being processed at the same time, one on each side of a connection (where both implementations are go-capnp, as opposed to some other language), each will try to send a correspdonding Finish message from within the receive loop, and it will not process any further messages until this finish has been written to the connection.

If the connection is unbuffered (e.g. net.Pipe), this could cause a deadlock, as neither side's send will complete until the other side tries to receive.

I suspect there may be other similar bugs. As a general principle, we should endeavor for the receive loop to never block, and I would be surprised if these were the only deadlock bugs that resulted from violating this general principle. (The cause of #189 itself is more complicated, but also involves blocked receive loops).

@zenhack
Copy link
Contributor Author

zenhack commented Nov 19, 2021

At some point I'd like to audit the implementation and pin down all the places the receive loop is blocking, and see if we can eliminate them.

@lthibault lthibault added the bug label Nov 19, 2021
@zenhack
Copy link
Contributor Author

zenhack commented Nov 19, 2021

(To clarify, obviously it is okay for the receive loop to block when waiting for a message to receive. But I think this is the only such case).

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants