Skip to content

Conversation

@Shourya742
Copy link
Contributor

Catch panics in subrequest callbacks, reply with Cancel, and propagate cancellation to the proc-macro server

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 6, 2026
Copy link
Contributor

@ChayimFriedman2 ChayimFriedman2 left a 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))) {
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants