chakrashim: exception of node-bootstrap.js not output currently while embeding as static library
- Version: v8.4.0
- Platform: macOS 10.12.6
- Subsystem:
hi, i m trying to embedding node-chakracore as a static library
but got fatal exception on calling node::Start(int argc, char** argv)
with these calling stacks (main steps cause problem)
- node::Start(int argc, char** argv) deps/node-chakracore/src/node.cc#5077
- ...
- node::LoadEnvironment(Environment* env) deps/node-chakracore/src/node.cc#3666
Local<Value> arg = env->process_object();
> f->Call(Null(env->isolate()), 1, &arg);
}
- ...
- v8::Function::Call(Local<Context> context, Handle<Value> recv, int argc, Handle<Value> argv[]) deps/node-chakracore/deps/chakrashim/src/v8function.cc#96
JsValueRef result;
{
TryCatch tryCatch;
tryCatch.SetNonUser();
if (JsCallFunction((JsValueRef)this, args, argc + 1,
&result) != JsNoError) {
> tryCatch.CheckReportExternalException();
return Local<Value>();
}
}
return Local<Value>::New(result);
}
- node::FatalException(Isolate* isolate, Local<Value> error, Local<Message> message) deps/node-chakracore/src/node.cc#2658
Environment* env = Environment::GetCurrent(isolate);
Local<Object> process_object = env->process_object();
Local<String> fatal_exception_string = env->fatal_exception_string();
> Local<Function> fatal_exception_function =
process_object->Get(fatal_exception_string).As<Function>();
int exit_code = 0;
if (!fatal_exception_function->IsFunction()) {
// failed before the process._fatalException function was added!
// this is probably pretty bad. Nothing to do but report and exit.
ReportException(env, error, message);
exit_code = 6;
}
- v8::Function::Cast(Value *obj) deps/node-chakracore/deps/chakrashim/src/v8function.cc#2783 https://github.com/nodejs/node-chakracore/blob/master/src/node.cc#L2783
Function *Function::Cast(Value *obj) {
printf("obj->IsFunction()? in Function::Cast %d\n", obj->IsFunction());
> CHAKRA_ASSERT(obj->IsFunction()); <<<<<< Thread 1: signal SIGABRT
return static_cast<Function*>(obj);
}
after comment the CHAKRA_ASSERT(obj->IsFunction()) in Function::Cast , only then i can got detail message of the exception
bootstrap_node.js:489
const ContextifyScript = process.binding('contextify').ContextifyScript;
^
Error: No such module: contextify
at Anonymous function (bootstrap_node.js:489:3)
Program ended with exit code: 6
after googling, i think is not a node-chakracore specific problem, and maybe i can try to figure out the solution with other issues.
- https://github.com/nodejs/node/issues/686#issuecomment-74559487
- https://github.com/electron/node/issues/4
for node-chakracore specific, i think there is another problem as title said
maybe the CHAKRA_ASSERT(obj->IsFunction()) in Function::Cast should not breaks the exception detail message output
reviewing the node::FatalException(Isolate* isolate, Local<Value> error, Local<Message> message) in deps/node-chakracore/src/node.cc#2657 i found maybe there is a little bit mistake with v8::Function::Cast in chakrashim.
see ***** comments below~
Environment* env = Environment::GetCurrent(isolate);
Local<Object> process_object = env->process_object();
Local<String> fatal_exception_string = env->fatal_exception_string();
// ***** the fatal_exception_string may not be a function
> Local<Function> fatal_exception_function =
process_object->Get(fatal_exception_string).As<Function>();
// ***** calling the CHAKRA_ASSERT(obj->IsFunction()) in Function::Cast, make breaks here
int exit_code = 0;
// ***** would never enter this if block while fatal_exception_function is not a function
if (!fatal_exception_function->IsFunction()) {
ReportException(env, error, message); // ***** so exception detail message never output
exit_code = 6;
}
for others who wants to embed node as static library, and have hit this issue could see this issue: janeasystems/nodejs-mobile#9
also reference this nodejs pull request nodejs/node#14986.
There were recently a whole bunch of changes to enable building as a static library in upstream. Do you know if this is fixed yet?