about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-07-31 23:39:41 +0200
committerGitHub <noreply@github.com>2022-07-31 23:39:41 +0200
commitc98e893badd1204797e261a0ebf2341f01ff1a61 (patch)
treecd91f013635fcebf08f8231cf0b26f9322742692
parent9cc06eb54d53e9b29d7ddcf3b26274cef335b75b (diff)
parent15b7a087471533086df538bc1a21b475f3ef032e (diff)
downloadrust-c98e893badd1204797e261a0ebf2341f01ff1a61.tar.gz
rust-c98e893badd1204797e261a0ebf2341f01ff1a61.zip
Rollup merge of #99932 - madsmtm:fix-unwinding-debug-assertions, r=Amanieu
Fix unwinding on certain platforms when debug assertions are enabled

This came up on `armv7-apple-ios` when using `-Zbuild-std`.

Looks like this is a leftover from a [conversion from C to Rust](051c2d14fb1e73866376668088971605d38f0c65), where integer wrapping is implicit.

Not at all sure how the unwinding code works!
-rw-r--r--library/panic_unwind/src/gcc.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/library/panic_unwind/src/gcc.rs b/library/panic_unwind/src/gcc.rs
index 057e47bfdd1..a596592311a 100644
--- a/library/panic_unwind/src/gcc.rs
+++ b/library/panic_unwind/src/gcc.rs
@@ -306,7 +306,9 @@ unsafe fn find_eh_action(context: *mut uw::_Unwind_Context) -> Result<EHAction,
     let eh_context = EHContext {
         // The return address points 1 byte past the call instruction,
         // which could be in the next IP range in LSDA range table.
-        ip: if ip_before_instr != 0 { ip } else { ip - 1 },
+        //
+        // `ip = -1` has special meaning, so use wrapping sub to allow for that
+        ip: if ip_before_instr != 0 { ip } else { ip.wrapping_sub(1) },
         func_start: uw::_Unwind_GetRegionStart(context),
         get_text_start: &|| uw::_Unwind_GetTextRelBase(context),
         get_data_start: &|| uw::_Unwind_GetDataRelBase(context),