Merge pull request #316 from ethereum/rust-panic

rust: unwind execution panics in evmc-declare
This commit is contained in:
Alex Beregszaszi 2019-06-06 13:27:37 +01:00 committed by GitHub
commit 9b2de67eda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 1 deletions

View File

@ -363,7 +363,15 @@ fn build_execute_fn(names: &VMNameSet) -> proc_macro2::TokenStream {
::evmc_vm::EvmcContainer::<#type_name_ident>::from_ffi_pointer(instance)
};
let result = container.execute(code_ref, &execution_context);
let result = ::std::panic::catch_unwind(|| {
container.execute(code_ref, &execution_context)
});
let result = if result.is_err() {
::evmc_vm::ExecutionResult::new(::evmc_vm::ffi::evmc_status_code::EVMC_INTERNAL_ERROR, 0, None)
} else {
result.unwrap()
};
unsafe {
::evmc_vm::EvmcContainer::into_ffi_pointer(container);