Skip to content

Commit ef9bfd4

Browse files
committed
Only clear io buffer after unsuccesfull guest call.
Signed-off-by: Ludvig Liljenberg <[email protected]> Undo stuff that breaks unwinding Signed-off-by: Ludvig Liljenberg <[email protected]>
1 parent 058a4de commit ef9bfd4

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/hyperlight_host/src/sandbox/initialized_multi_use.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,14 @@ impl MultiUseSandbox {
423423
.get_guest_function_call_result()
424424
})();
425425

426-
// TODO: Do we want to allow re-entrant guest function calls?
427-
self.get_mgr_wrapper_mut().as_mut().clear_io_buffers();
428-
426+
// In the happy path we do not need to clear io-buffers from the host because:
427+
// - the serialized guest function call is zeroed out by the guest during deserialization, see call to `try_pop_shared_input_data_into::<FunctionCall>()`
428+
// - the serialized guest function result is zeroed out by us (the host) during deserialization, see `get_guest_function_call_result`
429+
// - any serialized host function call are zeroed out by us (the host) during deserialization, see `get_host_function_call`
430+
// - any serialized host function result is zeroed out by the guest during deserialization, see `get_host_return_value`
431+
if res.is_err() {
432+
self.get_mgr_wrapper_mut().as_mut().clear_io_buffers();
433+
}
429434
res
430435
}
431436

0 commit comments

Comments
 (0)