wasm-bindgen icon indicating copy to clipboard operation
wasm-bindgen copied to clipboard

"memory access out of bounds" on allocating large structs.

Open karikera opened this issue 1 year ago • 0 comments

Describe the Bug

memory access out of bounds on allocating large structs.

runtime error

[email protected]

Steps to Reproduce


#[wasm_bindgen]
pub struct FoobarPass {
    buf:[i32; 1024*512],
}

#[wasm_bindgen]
pub fn foobar_pass()->FoobarPass { // it's okay
    FoobarPass{
        buf: [0; 1024*512],
    }
}

#[wasm_bindgen]
pub struct FoobarFail {
    buf:[i32; 1024*256],
    n:i64,
}

#[wasm_bindgen]
pub fn foobar_fail()->FoobarFail { // it fails
    FoobarFail{
        buf: [0; 1024*256],
        n:0,
    }
}

Expected Behavior

no error

Actual Behavior

Uncaught RuntimeError RuntimeError: memory access out of bounds

karikera avatar May 05 '24 14:05 karikera