-
-
Notifications
You must be signed in to change notification settings - Fork 616
Description
Describe the bug
Passing a fixed length TypedArray that is backed by a SharedArrayBuffer into Object.preventExtensions causes the method to throw a TypeError. This goes against the ecma262 spec which permits this operation under sec-typedarray-preventextensions.
I'm fairly certain that this is why test262's test/staging/built-ins/Object/preventExtensions is failing.
To Reproduce
const rab = new SharedArrayBuffer(4, { maxByteLength: 8 });
const ta = new Uint8Array(rab, 0, 4);
try {
Object.preventExtensions(ta);
console.log("IsTypedArrayFixedLength() == true");
} catch (e) {
console.log("IsTypedArrayFixedLength() == false | " + e.name);
}Expected behavior
The output should be IsTypedArrayFixedLength() == true but it throws and outputs IsTypedArrayFixedLength() == false | TypeError. The relevant spec sections are sec-typedarray-preventextensions and sec-istypedarrayfixedlength
Build environment
- OS: Windows 11
- Version: 10.0.22631 Build 22631
- Target triple: [e.g. x86_64-unknown-linux-msvc]
- Rustc version: rustc 1.94.0 (4a4ef493e 2026-03-02)
Additional context
The current implementation of typed_array_exotic_prevent_extensions incorrectly attempts to implement IsTypedArrayFixedLength with the following line:
ta.viewed_array_buffer().as_buffer().is_fixed_len()The is_fixed_len method has no means to check whether the TypedArray is length is AUTO. It also dispatches to the corresponding is_fixed_len method on ArrayBuffer or SharedArrayBuffer which logically makes sense but the spec only cares for the case of fixed-length ArrayBuffers (and for this, IsTypedArrayFixedLength is false). The fix should merely involve adding this two checks.