Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions src/wasmtime/crates/lind-multi-process/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ impl<
// word), making start > end and firing the bounds-check ud2 every time.
*(unwind_data_start_sys as *mut u32) =
(unwind_data_start_usr + UNWIND_METADATA_SIZE) as u32;
*((unwind_data_start_sys + 4) as *mut u32) = stack_pointer as u32;
*((unwind_data_start_sys + 4) as *mut u32) = stack_pointer;
}

let get_cx = self.get_cx.clone();
Expand Down Expand Up @@ -887,7 +887,7 @@ impl<
unsafe {
*(parent_unwind_data_start_sys as *mut u32) =
(parent_unwind_data_start_usr + UNWIND_METADATA_SIZE) as u32;
*((parent_unwind_data_start_sys + 4) as *mut u32) = stack_pointer as u32;
*((parent_unwind_data_start_sys + 4) as *mut u32) = stack_pointer;
}

// set up child_tid
Expand Down Expand Up @@ -968,7 +968,7 @@ impl<
store.set_on_called(Box::new(move |mut store| {
// once unwind is finished, buf[0] (u32) holds the final write position
let parent_unwind_data_end_usr =
unsafe { *(parent_unwind_data_start_sys as *mut u32) } as u64;
unsafe { *(parent_unwind_data_start_sys as *const u32) } as u64;

// unwind finished and we need to stop the unwind
let _res = asyncify_stop_unwind_func.call(&mut store, ());
Expand Down Expand Up @@ -1459,7 +1459,7 @@ impl<
unsafe {
*(parent_unwind_data_start_sys as *mut u32) =
(parent_unwind_data_start_usr + UNWIND_METADATA_SIZE) as u32;
*((parent_unwind_data_start_sys + 4) as *mut u32) = stack_pointer as u32;
*((parent_unwind_data_start_sys + 4) as *mut u32) = stack_pointer;
}

// mark the start of unwind
Expand Down Expand Up @@ -1580,7 +1580,7 @@ impl<
unsafe {
*(parent_unwind_data_start_sys as *mut u32) =
(parent_unwind_data_start_usr + UNWIND_METADATA_SIZE) as u32;
*((parent_unwind_data_start_sys + 4) as *mut u32) = stack_pointer as u32;
*((parent_unwind_data_start_sys + 4) as *mut u32) = stack_pointer;
}

// mark the start of unwind
Expand Down Expand Up @@ -1655,7 +1655,7 @@ impl<
unsafe {
*(unwind_data_start_sys as *mut u32) =
(unwind_data_start_usr + UNWIND_METADATA_SIZE) as u32;
*((unwind_data_start_sys + 4) as *mut u32) = stack_pointer as u32;
*((unwind_data_start_sys + 4) as *mut u32) = stack_pointer;
}

// mark the start of unwind
Expand All @@ -1673,7 +1673,7 @@ impl<
let store = caller.as_context_mut().0;
store.set_on_called(Box::new(move |mut store| {
// once unwind is finished, buf[0] (u32) holds the final write position
let unwind_data_end_usr = unsafe { *(unwind_data_start_sys as *mut u32) } as u64;
let unwind_data_end_usr = unsafe { *(unwind_data_start_sys as *const u32) } as u64;

// unwind finished and we need to stop the unwind
let _res = asyncify_stop_unwind_func.call(&mut store, ());
Expand All @@ -1683,8 +1683,10 @@ impl<
// store the unwind data
let hash =
store.store_unwind_data(unwind_data_start_sys as *const u8, rewind_total_size);

let jmp_buf_sys = cloned_address + jmp_buf as u64;
unsafe {
std::ptr::write_unaligned((cloned_address + jmp_buf as u64) as *mut u64, hash);
std::ptr::write_unaligned(jmp_buf_sys as *mut u64, hash);
}

// mark the parent to rewind state
Expand Down Expand Up @@ -1733,7 +1735,7 @@ impl<
unsafe {
*(unwind_data_start_sys as *mut u32) =
(unwind_data_start_usr + UNWIND_METADATA_SIZE) as u32;
*((unwind_data_start_sys + 4) as *mut u32) = stack_pointer as u32;
*((unwind_data_start_sys + 4) as *mut u32) = stack_pointer;
}

// mark the start of unwind
Expand All @@ -1753,8 +1755,8 @@ impl<
// unwind finished and we need to stop the unwind
let _res = asyncify_stop_unwind_func.call(&mut store, ());

let hash =
unsafe { std::ptr::read_unaligned((cloned_address + jmp_buf as u64) as *mut u64) };
let jmp_buf_sys = cloned_address + jmp_buf as u64;
let hash = unsafe { std::ptr::read_unaligned(jmp_buf_sys as *const u64) };
// retrieve the unwind data
let data = store.retrieve_unwind_data(hash);

Expand Down