From cb898bd37c0f7b833ba95ee9544d4b972a961c3e Mon Sep 17 00:00:00 2001 From: Midas Lambrichts Date: Sat, 5 Jun 2021 00:56:12 +0200 Subject: [PATCH 1/2] Fix #2389. Replace `Rip` with `Eip` `Rip` does not exist, `Eip`. This now seems to compile, but for me it generates an error during linking. --- lib/vm/src/trap/traphandlers.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vm/src/trap/traphandlers.rs b/lib/vm/src/trap/traphandlers.rs index ad5c6e42d9e..ad0eb8eb8f2 100644 --- a/lib/vm/src/trap/traphandlers.rs +++ b/lib/vm/src/trap/traphandlers.rs @@ -341,7 +341,7 @@ cfg_if::cfg_if! { None => return EXCEPTION_CONTINUE_SEARCH, }; let jmp_buf = info.handle_trap( - (*(*exception_info).ContextRecord).Rip as *const u8, + (*(*exception_info).ContextRecord).Eip as *const u8, record.ExceptionCode == EXCEPTION_STACK_OVERFLOW, // TODO: fix the signal trap associated to memory access in Windows None, From 9d4b9b1423319d183558b0401af2bc16eb10b387 Mon Sep 17 00:00:00 2001 From: Midas Lambrichts Date: Sat, 5 Jun 2021 01:33:29 +0200 Subject: [PATCH 2/2] Make the context record struct access dependent on 32 or 64 bit. Use target pointer width to determine 32 or 64 bit system and choose either Eip or Rip respectively for getting the program counter. --- lib/vm/src/trap/traphandlers.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/vm/src/trap/traphandlers.rs b/lib/vm/src/trap/traphandlers.rs index ad0eb8eb8f2..aff2b443a23 100644 --- a/lib/vm/src/trap/traphandlers.rs +++ b/lib/vm/src/trap/traphandlers.rs @@ -340,8 +340,14 @@ cfg_if::cfg_if! { Some(info) => info, None => return EXCEPTION_CONTINUE_SEARCH, }; + #[cfg(target_pointer_width = "32")] + let pc = (*(*exception_info).ContextRecord).Eip as *const u8; + + #[cfg(target_pointer_width = "64")] + let pc = (*(*exception_info).ContextRecord).Rip as *const u8; + let jmp_buf = info.handle_trap( - (*(*exception_info).ContextRecord).Eip as *const u8, + pc, record.ExceptionCode == EXCEPTION_STACK_OVERFLOW, // TODO: fix the signal trap associated to memory access in Windows None,