Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: fix rkyv alignment #1780

Draft
wants to merge 4 commits into
base: bing/rkyv-access
Choose a base branch
from
Draft
Changes from 1 commit
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
Prev Previous commit
Next Next commit
better
codeblooded1729 committed Jun 17, 2024
commit aacbed15d3427b5fa3414f4a0600de253c742e2a
11 changes: 5 additions & 6 deletions sdk/src/common/system.rs
Original file line number Diff line number Diff line change
@@ -104,14 +104,13 @@ fn populate_call_tape(self_prog_id: ProgramIdentifier) -> CallTapeType {
let mut len_bytes = [0; 4];
call_tape_read(&mut len_bytes);
let len: usize = u32::from_le_bytes(len_bytes).try_into().unwrap();
let buf: &'static mut Vec<u8> = Box::leak(Box::new(vec![0; len]));
let buf: &'static mut AlignedVec = Box::leak(Box::new(AlignedVec::with_capacity(len)));
unsafe {
buf.set_len(len);
}
call_tape_read(buf);
let mut aligned_buf = AlignedVec::with_capacity(len);
aligned_buf.extend_from_slice(&buf);
let aligned_buf_ptr: &'static mut AlignedVec = Box::leak(Box::new(aligned_buf));

let archived_cpc_messages =
rkyv::access::<Vec<CrossProgramCall>, Panic>(aligned_buf_ptr).unwrap();
let archived_cpc_messages = rkyv::access::<Vec<CrossProgramCall>, Panic>(buf).unwrap();

let cast_list: Vec<ProgramIdentifier> = archived_cpc_messages
.iter()