rust: catch exceptions in the entire execute() wrapper
@@ -337,6 +337,7 @@ fn build_execute_fn(names: &VMNameSet) -> proc_macro2::TokenStream {
{
use evmc_vm::EvmcVm;
+ let result = ::std::panic::catch_unwind(|| {
assert!(!instance.is_null());
// TODO: context is optional in case of the "precompiles" capability
assert!(!context.is_null());
@@ -360,11 +361,16 @@ fn build_execute_fn(names: &VMNameSet) -> proc_macro2::TokenStream {
::evmc_vm::EvmcContainer::<#type_name_ident>::from_ffi_pointer(instance)
};
- let result = ::std::panic::catch_unwind(|| {
let mut execution_context = unsafe {
::evmc_vm::ExecutionContext::new(context.as_mut().expect("EVMC context is null"))
};
- container.execute(revision, code_ref, &execution_message, &mut execution_context)
+ let result = container.execute(revision, code_ref, &execution_message, &mut execution_context);
+
+ unsafe {
+ ::evmc_vm::EvmcContainer::into_ffi_pointer(container);
+ }
+
+ result
});
let result = if result.is_err() {
@@ -374,10 +380,6 @@ fn build_execute_fn(names: &VMNameSet) -> proc_macro2::TokenStream {
result.unwrap()
};
- unsafe {
- ::evmc_vm::EvmcContainer::into_ffi_pointer(container);
- }
-
result.into()
}
}
