Skip to content

MessagePort.postMessage with custom iterator as transfer list causes Assertion `(index) < (length())' failed. #49940

@KhafraDev

Description

@KhafraDev

Version

v21.0.0-pre (I assume every version w/ structuredClone)

Platform

Linux DESKTOP-L4O1H93 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

structuredClone({}, {
  transfer: {
    *[Symbol.iterator]() {}
  }
})

or

new MessageChannel().port1.postMessage({}, {
  transfer: {
    *[Symbol.iterator]() {}
  }
})

How often does it reproduce? Is there a required condition?

No response

What is the expected behavior? Why is that the expected behavior?

this should work and return an empty object

What do you see instead?

./node[4717]: ../../src/util.h:392:T& node::MaybeStackBuffer<T, kStackStorageSize>::operator[](size_t) [with T = v8::Local<v8::Value>; long unsigned int kStackStorageSize = 8; size_t = long unsigned int]: Assertion `(index) < (length())' failed.
 1: 0x561c3fcd9e94 node::Abort() [./node]
 2: 0x561c3fcd9f28  [./node]
 3: 0x561c3fd3310c  [./node]
 4: 0x561c3fd35a4e node::worker::MessagePort::PostMessage(v8::FunctionCallbackInfo<v8::Value> const&) [./node]
 5: 0x561c3ffb4c00 v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo) [./node]
 6: 0x561c3ffb54f9  [./node]
 7: 0x561c3ffb59e5 v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [./node]
 8: 0x561c40a14df6  [./node]
Aborted

Additional information

The webidl states that a sequence is basically anything with a Symbol.iterator, not exclusive to arrays. https://webidl.spec.whatwg.org/#es-sequence

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions