Open
Description
Describe the Bug
Closely related to #4395 - TypedArray::from
with slice input sporadically fails: "Cannot perform Construct on a detached ArrayBuffer". It uses TypedArray::view
:
wasm-bindgen/crates/js-sys/src/lib.rs
Lines 6379 to 6385 in c35cc93
Note that the function is not marked unsafe
itself.
Steps to Reproduce
Add test case to crates/js-sys/tests/wasm/TypedArray.rs
:
#[wasm_bindgen_test]
fn from_succeeds_when_heap_grows() {
let _ = (0..10_000).map(|i| {
Int32Array::from([i].as_slice())
}).collect::<Vec<_>>();
}
Run test:
# cargo test --target wasm32-unknown-unknown from_succeeds_when_heap_grows
[...]
running 1 test
test TypedArray::from_succeeds_when_heap_grows ... FAIL
failures:
---- TypedArray::from_succeeds_when_heap_grows output ----
error output:
wasm-bindgen: imported JS function that was not marked as `catch` threw an error: Cannot perform Construct on a detached ArrayBuffer
Stack:
TypeError: Cannot perform Construct on a detached ArrayBuffer
at new Int32Array (<anonymous>)