Dynamic import attributes broken with multiple attributes #50700
Copy link
Copy link
Closed
Labels
confirmed-bugIssues and PRs for confirmed bugs.Issues and PRs for confirmed bugs.esmIssues and PRs related to the ECMAScript Modules implementation.Issues and PRs related to the ECMAScript Modules implementation.
Description
Activity
- addedconfirmed-bugIssues and PRs for confirmed bugs.Issues and PRs for confirmed bugs.esmIssues and PRs related to the ECMAScript Modules implementation.Issues and PRs related to the ECMAScript Modules implementation.
on Nov 13, 2023 - changed the title
[-]Dynamic `import` attributes broken with custom attributes[/-][+]Dynamic `import` attributes broken with multiple attributes[/+]on Nov 13, 2023 I thought this would be easy to fix when I saw
Line 256 in 0304da2
for (int i = 0; i < raw_attributes->Length(); i += 3) { But this is not just an off-by-one issue.
For
import(jsModuleDataUrl, { with: { type: 'json', other: 'unsupported' } })(test I added), theraw_attributesarray contains 4 elements.For
import(`data:text/javascript,import${JSON.stringify(jsModuleDataUrl)}with{type:"json"}`)(existing test), it contains 3 elements.I don't understand how it's possible. The array is guaranteed to have a size that's a multiple of two:
node/deps/v8/src/execution/isolate.cc
Lines 5446 to 5448 in 0304da2
constexpr size_t kAssertionEntrySizeForDynamicImport = 2; import_assertions_array = factory()->NewFixedArray(static_cast<int>( assertion_keys->length() * kAssertionEntrySizeForDynamicImport)); Debug build makes it a bit more understandable:
$ ./node_g test/es-module/test-esm-import-attributes-errors.mjs FATAL ERROR: v8::String::Cast Value is not a String ----- Native stack trace ----- 1: 0x100645944 node::DumpNativeBacktrace(__sFILE*) [/Users/mzasso/git/nodejs/node/out/Debug/node] 2: 0x100784638 node::Abort() [/Users/mzasso/git/nodejs/node/out/Debug/node] 3: 0x100784798 node::OOMErrorHandler(char const*, v8::OOMDetails const&) [/Users/mzasso/git/nodejs/node/out/Debug/node] 4: 0x100b344fc v8::String::CheckCast(v8::Data*) [/Users/mzasso/git/nodejs/node/out/Debug/node] 5: 0x1005fd248 v8::String::Cast(v8::Data*) [/Users/mzasso/git/nodejs/node/out/Debug/node] 6: 0x1006ed5e8 v8::Local<v8::String> v8::Local<v8::String>::Cast<v8::Data>(v8::Local<v8::Data>) [/Users/mzasso/git/nodejs/node/out/Debug/node] 7: 0x1006ed590 v8::Local<v8::String> v8::Local<v8::Data>::As<v8::String>() const [/Users/mzasso/git/nodejs/node/out/Debug/node] 8: 0x1006ea2dc node::loader::createImportAttributesContainer(node::Environment*, v8::Isolate*, v8::Local<v8::FixedArray>) [/Users/mzasso/git/nodejs/node/out/Debug/node]Found the issue: #50703
- added a commit that references this issue
on Nov 15, 2023 - added a commit that references this issue
on Nov 19, 2023 - added a commit that references this issue
on Nov 23, 2023 - added a commit that references this issue
on Nov 27, 2023 - added 2 commits that reference this issue
on Nov 29, 2023 - added 2 commits that reference this issue
on Dec 13, 2023 - added 2 commits that reference this issue
on Dec 15, 2023 - added a commit that references this issue
on Jan 9, 2024 - added a commit that references this issue
on Mar 18, 2024
Metadata
Metadata
Assignees
Labels
confirmed-bugIssues and PRs for confirmed bugs.Issues and PRs for confirmed bugs.esmIssues and PRs related to the ECMAScript Modules implementation.Issues and PRs related to the ECMAScript Modules implementation.
I was trying to adapt a V8 test to run it in Node.js
The following version fails in a C++ CHECK (it doesn't matter if the json file exists or not):
This happens in Node.js 21 and v20.x-staging.