@@ -13,6 +13,7 @@ use crate::module::{self, FunctionHandle, FunctionPointer, Global, GlobalValue,
1313use crate :: region:: RegionInternal ;
1414use crate :: val:: { UntypedRetVal , Val } ;
1515use crate :: WASM_PAGE_SIZE ;
16+ use backtrace:: Backtrace ;
1617use libc:: { c_void, siginfo_t, uintptr_t} ;
1718use lucet_module:: InstanceRuntimeData ;
1819use memoffset:: offset_of;
@@ -914,6 +915,7 @@ impl Instance {
914915 mut details,
915916 siginfo,
916917 context,
918+ full_backtrace,
917919 } => {
918920 // Sandbox is no longer runnable. It's unsafe to determine all error details in the signal
919921 // handler, so we fill in extra details here.
@@ -924,11 +926,15 @@ impl Instance {
924926 . module
925927 . addr_details ( details. rip_addr as * const c_void ) ?;
926928
929+ details. backtrace = Some ( self . module . resolve_and_trim ( & full_backtrace) ) ;
930+ // dbg!(&details.backtrace);
931+
927932 // fill the state back in with the updated details in case fatal handlers need it
928933 self . state = State :: Faulted {
929934 details : details. clone ( ) ,
930935 siginfo,
931936 context,
937+ full_backtrace,
932938 } ;
933939
934940 if details. fatal {
@@ -1109,6 +1115,8 @@ pub struct FaultDetails {
11091115 pub rip_addr : uintptr_t ,
11101116 /// Extra information about the instruction pointer's location, if available.
11111117 pub rip_addr_details : Option < module:: AddrDetails > ,
1118+ /// Backtrace of the frames from the guest stack, if available.
1119+ pub backtrace : Option < Backtrace > ,
11121120}
11131121
11141122impl std:: fmt:: Display for FaultDetails {
0 commit comments