incubator-teaclave-sgx-sdk: getting backtrace from panics in the enclave

Hi, Do you have any ideas on how I can get a backtrace when I have a panic in the enclave?

Right now all I get is something like this:

thread panicked at 'Box<Any>', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/hashbrown-0.3.0/src/raw/mod.rs:1078:9

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Comments: 21 (20 by maintainers)

Most upvoted comments

and i have to add more tests for alignment-critical crates — such as crates as hashbrown, ring, other stuffs related to sse or avx instructions. and more tests against low-level APIs.

@elichai

Confused. I enabled the backtrace feature by editing enclave/Cargo.toml:

-sgx_tstd = { git = "https://github.com/baidu/rust-sgx-sdk.git", rev = "v1.0.7" }
+sgx_tstd = { git = "https://github.com/baidu/rust-sgx-sdk.git", rev = "v1.0.7", feat
ures = ["backtrace"] }

Then add this to enclave/lib.rs

 extern crate sgx_tstd as std;
 extern crate sgx_types;

+use std::backtrace::{self, PrintFormat};
+
 extern crate parity_wasm;
 extern crate wasmi;

@@ -18,6 +20,9 @@ use wasmi::{ImportsBuilder, ModuleInstance, NopExternals, RuntimeValue};

 #[no_mangle]
 pub extern "C" fn ecall_main() -> sgx_status_t {
+
+    let _ = backtrace::enable_backtrace("enclave.signed.so", PrintFormat::Full);
+
     let path = get_code_path();
     println!("{:?}", path);

Then it no longer panics! I don’t even have a chance to inspect on the stack unwinding info…