Skip to content

Commit 97e42a4

Browse files
committed
Fixes an issue where errors do not get propogated correctly when the hypervisor handler thread returns an error.
The hypervisor handler thread can return an error rather than send a message, in this case the error returned would be a timeout rather than the real error, this change ensures that we check for an error in the hypervisor handler thread when we time out and return that if it exists Signed-off-by: Simon Davies <[email protected]>
1 parent afbd1af commit 97e42a4

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/hyperlight_host/src/hypervisor/hypervisor_handler.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,29 @@ impl HypervisorHandler {
592592
HandlerMsg::Error(e) => Err(e),
593593
HandlerMsg::FinishedHypervisorHandlerAction => Ok(()),
594594
},
595-
Err(_) => Err(HyperlightError::HypervisorHandlerMessageReceiveTimedout()),
595+
Err(_) => {
596+
// If we have timed out it may be that the handler thread returned an error before it sent a message, so rather than just timeout here
597+
// we will try and get the join handle for the thread and if it has finished check to see if it returned an error
598+
// if it did then we will return that error, otherwise we wil return the timeout error
599+
match self
600+
.execution_variables
601+
.join_handle
602+
.try_lock()
603+
.map_err(|_| HyperlightError::HypervisorHandlerMessageReceiveTimedout())?
604+
.take()
605+
{
606+
Some(handle) => {
607+
if handle.is_finished() {
608+
let res = handle.join();
609+
if res.as_ref().is_ok_and(|inner_res| inner_res.is_err()) {
610+
return Err(res.unwrap().unwrap_err());
611+
}
612+
}
613+
Err(HyperlightError::HypervisorHandlerMessageReceiveTimedout())
614+
}
615+
None => Err(HyperlightError::HypervisorHandlerMessageReceiveTimedout()),
616+
}
617+
}
596618
}
597619
}
598620

0 commit comments

Comments
 (0)