Revert "rust: catch exceptions in the entire execute() wrapper"

This reverts commit 99ca1e2b63.
This commit is contained in:
Alex Beregszaszi 2019-08-10 00:04:52 +02:00
parent 8778c6e4c3
commit 1e339d7bb2
1 changed files with 28 additions and 30 deletions

View File

@ -337,40 +337,34 @@ fn build_execute_fn(names: &VMNameSet) -> proc_macro2::TokenStream {
{
use evmc_vm::EvmcVm;
assert!(!instance.is_null());
// TODO: context is optional in case of the "precompiles" capability
assert!(!context.is_null());
assert!(!msg.is_null());
let execution_message: ::evmc_vm::ExecutionMessage = unsafe {
msg.as_ref().expect("EVMC message is null").into()
};
let empty_code = [0u8;0];
let code_ref: &[u8] = if code.is_null() {
assert_eq!(code_size, 0);
&empty_code
} else {
unsafe {
::std::slice::from_raw_parts(code, code_size)
}
};
let container = unsafe {
::evmc_vm::EvmcContainer::<#type_name_ident>::from_ffi_pointer(instance)
};
let result = ::std::panic::catch_unwind(|| {
assert!(!instance.is_null());
// TODO: context is optional in case of the "precompiles" capability
assert!(!context.is_null());
assert!(!msg.is_null());
let execution_message: ::evmc_vm::ExecutionMessage = unsafe {
msg.as_ref().expect("EVMC message is null").into()
};
let empty_code = [0u8;0];
let code_ref: &[u8] = if code.is_null() {
assert_eq!(code_size, 0);
&empty_code
} else {
unsafe {
::std::slice::from_raw_parts(code, code_size)
}
};
let container = unsafe {
::evmc_vm::EvmcContainer::<#type_name_ident>::from_ffi_pointer(instance)
};
let mut execution_context = unsafe {
::evmc_vm::ExecutionContext::new(context.as_mut().expect("EVMC context is null"))
};
let result = container.execute(revision, code_ref, &execution_message, &mut execution_context);
unsafe {
::evmc_vm::EvmcContainer::into_ffi_pointer(container);
}
result
container.execute(revision, code_ref, &execution_message, &mut execution_context)
});
let result = if result.is_err() {
@ -380,6 +374,10 @@ fn build_execute_fn(names: &VMNameSet) -> proc_macro2::TokenStream {
result.unwrap()
};
unsafe {
::evmc_vm::EvmcContainer::into_ffi_pointer(container);
}
result.into()
}
}