Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

chakrashim: exception of node-bootstrap.js not output currently while embeding as static library #409

Open
tommyZZM opened this issue Oct 3, 2017 · 2 comments

Comments

@tommyZZM
Copy link

tommyZZM commented Oct 3, 2017

  • 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);
 }
  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);
}
   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;
   }
  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.


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;
   }
@tommyZZM
Copy link
Author

tommyZZM commented Oct 7, 2017

for others who wants to embed node as static library, and have hit this issue
could see this issue: JaneaSystems#9

also reference this nodejs pull request nodejs/node#14986.

@tommyZZM tommyZZM changed the title chakrashim: exception of node-bootstrap.js not output currently while embedding as static library chakrashim: exception of node-bootstrap.js not output currently while embeding as static library Oct 7, 2017
@jackhorton
Copy link
Contributor

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?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants