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 deadlock #316

Merged
merged 2 commits into from
Oct 1, 2022
Merged

Fix deadlock #316

merged 2 commits into from
Oct 1, 2022

Conversation

zenhack
Copy link
Contributor

@zenhack zenhack commented Oct 1, 2022

See the first commit message. The second commit fixes similar logic errors, though I haven't seen consequences of those errors.

There are some other tests that occasionally deadlock, but I haven't tracked down the cause yet.

It is illegal to resolve promises while holding connection locks, and I
was seeing TestHandleReturn_regression deadlock every 6th run or so;
changing this fixes it.

Note: since this makes the resolution itself and the manipulation of
the questions table non-atomic, the ordering is critical:

1. First we remove the entry from the table. This means that if the
remote vat sends us messages pertaining to that question id, they will
simply be rejected instead being acted on. This shouldn't happen
normally, but maybe a malicious vat could get us to panic or something.
2. Second, resolve the promise. After this is complete, we can be sure
the client won't be used.
3. Then, and only then, we can return the question id to the pool for
re-use.
Unlike the previous commit, I haven't observed the consequences of
these, but the same logic & ordering constraints apply.
@zenhack zenhack mentioned this pull request Oct 1, 2022
@zenhack zenhack merged commit 00c7c66 into capnproto:main Oct 1, 2022
@zenhack zenhack deleted the fix-deadlock branch October 1, 2022 06:43
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.

2 participants