From 9084c1781ee58c1782d51b30e663008897e87ffc Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Fri, 29 Mar 2024 10:23:21 +0100 Subject: [PATCH] Repair nested-panic situation --- syndicate/src/actor.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/syndicate/src/actor.rs b/syndicate/src/actor.rs index 50d70c1..c4c52ed 100644 --- a/syndicate/src/actor.rs +++ b/syndicate/src/actor.rs @@ -1837,7 +1837,16 @@ impl Activation { ) { match &*exit_status { ExitStatus::Normal => assert!(self.get_facet(self.root).is_none()), - ExitStatus::Dropped | ExitStatus::Error(_) => (), + ExitStatus::Dropped => { + // If we panicked, facet_id will be Some(_), but leaving it this way as we + // enter take_turn causes a nested panic, so we clear it here. + if self.facet_id.is_some() { + tracing::debug!(actor_id=?self.actor_id, facet_id=?self.facet_id, + "clearing facet_id (we must have panicked mid-Turn)"); + self.facet_id = None; + } + } + ExitStatus::Error(_) => (), } let cause = Some(trace::TurnCause::Cleanup);