-
Notifications
You must be signed in to change notification settings - Fork 431
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
Mis-aligned allocation in ink #1535
Comments
@kvinwang can you share the code that you're trying to run? |
Here is the project I am working on.
git clone https://github.com/kvinwang/qjs.git --recursive
cd qjs
Now we got a compiled contract with a method |
@kvinwang Sorry for picking this up late. The links seem to be broken. Can you please either update them or confirm the issue? |
Just for records. I managed to partially reproduce the issue by inspecting logs from #[ink(message)]
pub fn buffer(&self) {
let buf1 = Vec::<u8>::with_capacity(3);
let buf2 = Vec::<u64>::with_capacity(1);
ink::env::debug_println!("ptr to buf1 :{:?}", buf1.as_ptr());
ink::env::debug_println!("ptr to buf2 :{:?}", buf2.as_ptr());
ink::env::debug_println!("align of u64:{}", align_of::<u64>());
} |
I am trying to port the quickjs runtime into ink. It always crashes because it rely on the heap allocation alignment.
Looks like the ink's bump allocator doesn't obey Rust's alignment requirements.
Given the follow code:
Runing in ink would get somthing like:
Where the ptr of buf2 is mis-aligned.
Expected behavior
It should be aligned as Rust's default allocator do. See here which meets the Allocator requirements.
The text was updated successfully, but these errors were encountered: