-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Make proc-macro bidirectional calls cancellation safe #21410
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
base: master
Are you sure you want to change the base?
Make proc-macro bidirectional calls cancellation safe #21410
Conversation
ChayimFriedman2
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few comments.
| let resp = callback(sr)?; | ||
| let reply = BidirectionalMessage::SubResponse(resp); | ||
| let encoded = C::encode(&reply).map_err(wrap_encode)?; | ||
| let resp = match catch_unwind(AssertUnwindSafe(|| callback(sr))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would slightly prefer to have the callback type + UnwindSafe than this AssertUnwindSafe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is tricky because the callback captures &dyn ExpandDatabase (later at implementation), which is not UnwindSafe. Requiring UnwindSafe on the callback would therefore force unwind-safety guarantees on ExpandDatabase.
Catch panics in subrequest callbacks, reply with Cancel, and propagate cancellation to the proc-macro server