Skip to content

Commit 3453415

Browse files
committed
[LSDA] Take ttype_index into account when taking action
If cs_action != 0, we should check the ttype_index field in action record. If ttype_index == 0, a clean up action is taken.
1 parent fbe8292 commit 3453415

File tree

1 file changed

+10
-2
lines changed
  • library/std/src/personality/dwarf

1 file changed

+10
-2
lines changed

library/std/src/personality/dwarf/eh.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pub unsafe fn find_eh_action(lsda: *const u8, context: &EHContext<'_>) -> Result
8484
let cs_start = read_encoded_pointer(&mut reader, context, call_site_encoding)?;
8585
let cs_len = read_encoded_pointer(&mut reader, context, call_site_encoding)?;
8686
let cs_lpad = read_encoded_pointer(&mut reader, context, call_site_encoding)?;
87-
let cs_action = reader.read_uleb128();
87+
let cs_action_entry = reader.read_uleb128();
8888
// Callsite table is sorted by cs_start, so if we've passed the ip, we
8989
// may stop searching.
9090
if ip < func_start + cs_start {
@@ -95,7 +95,15 @@ pub unsafe fn find_eh_action(lsda: *const u8, context: &EHContext<'_>) -> Result
9595
return Ok(EHAction::None);
9696
} else {
9797
let lpad = lpad_base + cs_lpad;
98-
return Ok(interpret_cs_action(cs_action, lpad));
98+
if cs_action_entry == 0 {
99+
return Ok(interpret_cs_action(0, lpad));
100+
} else {
101+
let action_record =
102+
(action_table as *mut u8).offset(cs_action_entry as isize - 1);
103+
let mut action_reader = DwarfReader::new(action_record);
104+
let ttype_index = action_reader.read_sleb128();
105+
return Ok(interpret_cs_action(ttype_index as u64, lpad));
106+
}
99107
}
100108
}
101109
}

0 commit comments

Comments
 (0)