You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
child_process: advanced serialization segfaults on a host object with an index property #67767
With a property that is not an index (port1.named = 'x'), the child receives {"named":"x"}.
How often does it reproduce? Is there a required condition?
Always, when the sent value is a host object (here a MessagePort) with an own enumerable index property.
What is the expected behavior? Why is that the expected behavior?
The child receives { '0': 'x' }. The C++ code is documented to send the same shallow copy as writeValue({ ...object }) in serialization.js. A JS error would also be acceptable, but not a crash.
What do you see instead?
Segmentation fault (exit code 139).
Additional information
SerializerDelegate::WriteHostObject in src/node_ipc_serdes.cc (the non-view branch) calls object->GetOwnPropertyNames(context). Its default KeyConversionMode is kKeepNumbers, so index keys come back as Smis. The loop then calls copy->CreateDataProperty(context, key.As<Name>(), val). As<Name>() is an unchecked cast, and V8 dereferences the Smi as a Name.
Requesting string keys fixes it: object->GetOwnPropertyNames(context, static_cast<PropertyFilter>(ONLY_ENUMERABLE | SKIP_SYMBOLS), KeyConversionMode::kConvertToString). Another option is to branch on key->IsUint32() and use the CreateDataProperty(context, uint32_t, value) overload.
Activity