Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crash after set process.default to any value and then firstly require or import process module #51480

Closed
LongTengDao opened this issue Jan 15, 2024 · 2 comments · Fixed by #51481

Comments

@LongTengDao
Copy link
Contributor

LongTengDao commented Jan 15, 2024

Version

v20.10.0

Platform

No response

Subsystem

seems loader init the esm builtin from cjs, which shown on process because only process module can be accessed before require/import.

What steps will reproduce the bug?

process.default = 1;
require('process');// crash
process.default = 1;
import('process');// crash
require('process');
process.default = 1;
require('process');// ok
import('process');// ok
process.x = 1;
import('process').then(processModule => {
    console.log('x' in processModule);// true
});

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

every time.

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

don't crash. and esm version should not use the modified cjs version to init its module names, if I'm right.

What do you see instead?

crash (even not throw).

Additional information

No response

@duncanchiu409
Copy link
Contributor

duncanchiu409 commented Jan 15, 2024

My question would be why would you use both module format at the same time. Sorry, the question might sounds junior. I am just curious.

@aduh95
Copy link
Contributor

aduh95 commented Jan 16, 2024

Here's the stack trace from the crash:

#
# Fatal error in , line 0
# Check failed: IsTheHole(exports->Lookup(name), isolate).
#
#
#
#FailureMessage Object: 0x16fdfd308
----- Native stack trace -----

 1: 0x10012d2e0 node::DumpNativeBacktrace(__sFILE*) […/out/Release/node]
 2: 0x1003752c8 node::NodePlatform::GetStackTracePrinter()::$_3::operator()() const […/out/Release/node]
 3: 0x100375284 node::NodePlatform::GetStackTracePrinter()::$_3::__invoke() […/out/Release/node]
 4: 0x1017f570c V8_Fatal(char const*, ...) […/out/Release/node]
 5: 0x100b3c658 v8::internal::SyntheticModule::PrepareInstantiate(v8::internal::Isolate*, v8::internal::Handle<v8::internal::SyntheticModule>, v8::Local<v8::Context>) […/out/Release/node]
 6: 0x100ae4b34 v8::internal::Module::Instantiate(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Module>, v8::Local<v8::Context>, v8::MaybeLocal<v8::Module> (*)(v8::Local<v8::Context>, v8::Local<v8::String>, v8::Local<v8::FixedArray>, v8::Local<v8::Module>), v8::MaybeLocal<v8::Module> (*)(v8::Local<v8::Context>, v8::Local<v8::String>, v8::Local<v8::Module>)) […/out/Release/node]
 7: 0x10064d88c v8::Module::InstantiateModule(v8::Local<v8::Context>, v8::MaybeLocal<v8::Module> (*)(v8::Local<v8::Context>, v8::Local<v8::String>, v8::Local<v8::FixedArray>, v8::Local<v8::Module>)) […/out/Release/node]
 8: 0x1001d6f04 node::loader::ModuleWrap::Instantiate(v8::FunctionCallbackInfo<v8::Value> const&) […/out/Release/node]
 9: 0x1010b29f8 Builtins_CallApiCallbackGeneric […/out/Release/node]
10: 0x1010b09b0 Builtins_InterpreterEntryTrampoline […/out/Release/node]
11: 0x1010b09b0 Builtins_InterpreterEntryTrampoline […/out/Release/node]
12: 0x1010b09b0 Builtins_InterpreterEntryTrampoline […/out/Release/node]
13: 0x1010b09b0 Builtins_InterpreterEntryTrampoline […/out/Release/node]
14: 0x1010b09b0 Builtins_InterpreterEntryTrampoline […/out/Release/node]
15: 0x1010b09b0 Builtins_InterpreterEntryTrampoline […/out/Release/node]
16: 0x1010b09b0 Builtins_InterpreterEntryTrampoline […/out/Release/node]
17: 0x1010b09b0 Builtins_InterpreterEntryTrampoline […/out/Release/node]
18: 0x1010b09b0 Builtins_InterpreterEntryTrampoline […/out/Release/node]
19: 0x1010b09b0 Builtins_InterpreterEntryTrampoline […/out/Release/node]
20: 0x1010b09b0 Builtins_InterpreterEntryTrampoline […/out/Release/node]
21: 0x1010b09b0 Builtins_InterpreterEntryTrampoline […/out/Release/node]
22: 0x1010b09b0 Builtins_InterpreterEntryTrampoline […/out/Release/node]
23: 0x1010ae6cc Builtins_JSEntryTrampoline […/out/Release/node]
24: 0x1010ae3b4 Builtins_JSEntry […/out/Release/node]
25: 0x1007c1c98 v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) […/out/Release/node]
26: 0x1007c15b8 v8::internal::Execution::Call(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, int, v8::internal::Handle<v8::internal::Object>*) […/out/Release/node]
27: 0x10065fe14 v8::Function::Call(v8::Local<v8::Context>, v8::Local<v8::Value>, int, v8::Local<v8::Value>*) […/out/Release/node]
28: 0x10022a118 node::builtins::BuiltinLoader::CompileAndCall(v8::Local<v8::Context>, char const*, int, v8::Local<v8::Value>*, node::Realm*) […/out/Release/node]
29: 0x100229f9c node::builtins::BuiltinLoader::CompileAndCall(v8::Local<v8::Context>, char const*, node::Realm*) […/out/Release/node]
30: 0x100398588 node::Realm::ExecuteBootstrapper(char const*) […/out/Release/node]
31: 0x1001e2f1c node::StartExecution(node::Environment*, char const*) […/out/Release/node]
32: 0x1001e2d10 node::StartExecution(node::Environment*, std::__1::function<v8::MaybeLocal<v8::Value> (node::StartExecutionCallbackInfo const&)>) […/out/Release/node]
33: 0x10007ddd0 node::LoadEnvironment(node::Environment*, std::__1::function<v8::MaybeLocal<v8::Value> (node::StartExecutionCallbackInfo const&)>) […/out/Release/node]
34: 0x1002f4de4 node::NodeMainInstance::Run(node::ExitCode*, node::Environment*) […/out/Release/node]
35: 0x1002f4a14 node::NodeMainInstance::Run() […/out/Release/node]
36: 0x1001e5ef4 node::StartInternal(int, char**) […/out/Release/node]
37: 0x1001e5b10 node::Start(int, char**) […/out/Release/node]
38: 0x1014a01c4 main […/out/Release/node]

My question would be why would you use both module format at the same time.

That seems irrelevant.

nodejs-github-bot pushed a commit that referenced this issue Jan 19, 2024
PR-URL: #51481
Fixes: #51480
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Medhansh404 pushed a commit to Medhansh404/node that referenced this issue Jan 19, 2024
PR-URL: nodejs#51481
Fixes: nodejs#51480
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
marco-ippolito pushed a commit to marco-ippolito/node that referenced this issue Jan 22, 2024
PR-URL: nodejs#51481
Fixes: nodejs#51480
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
marco-ippolito pushed a commit to marco-ippolito/node that referenced this issue Feb 2, 2024
PR-URL: nodejs#51481
Fixes: nodejs#51480
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
targos pushed a commit that referenced this issue Feb 15, 2024
PR-URL: #51481
Fixes: #51480
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
marco-ippolito pushed a commit to marco-ippolito/node that referenced this issue Feb 19, 2024
PR-URL: nodejs#51481
Fixes: nodejs#51480
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
richardlau pushed a commit that referenced this issue Mar 25, 2024
PR-URL: #51481
Fixes: #51480
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
richardlau pushed a commit that referenced this issue Mar 25, 2024
PR-URL: #51481
Fixes: #51480
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants