// const char* src comes as argument
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::HandleScope hScope(isolate);
v8::Local<v8::Context> context = context_.Get(isolate);
v8::Context::Scope ctxScope(context);
v8::Local<v8::String> source = v8::String::NewFromUtf8(isolate, src);
v8::Local<v8::Script> script = v8::Script::Compile(isolate->GetCurrentContext(), source).ToLocalChecked();
v8::TryCatch trycatch(isolate);
v8::Local<v8::Value> v = script->Run(isolate->GetCurrentContext()).ToLocalChecked();
if (v.IsEmpty()) {
v8::Local<v8::Value> exception = trycatch.Exception();
v8::String::Utf8Value exceptionStr(isolate, exception);
}
Javascript:
log("first line");
log("second line");
var a = 2;
var b = 5;
var c = a + b;
log("" + c); // My C++ callback assumes arguments is String :-)
var d = new Something(); // crash here
I've also tried with these start-up options:
--stack-size=4096 --abort_on_uncaught_exception=false --hard-abort=false
This is the crash code:
2019-07-17 15:19:51.919 23748-23748/?: Instance.cpp:16: Log callback: first line
2019-07-17 15:19:51.919 23748-23748/?: Instance.cpp:16: Log callback: second line
2019-07-17 15:19:51.919 23748-23748/?: Instance.cpp:16: Log callback: 7
2019-07-17 15:19:51.988 23785-23785/? A/DEBUG: signal 5 (SIGTRAP), code 1 (TRAP_BRKPT), fault addr 0x7f2da5f4ac
2019-07-17 15:19:51.988 23785-23785/? A/DEBUG: x0 000000000000003e x1 0000000000000000 x2 3a64889416988361 x3 0000000000000001
2019-07-17 15:19:51.988 23785-23785/? A/DEBUG: x4 0000007f2e082ea3 x5 0000007fda9767ce x6 0000000000000008 x7 000000000a0a230a
2019-07-17 15:19:51.988 23785-23785/? A/DEBUG: x8 0000000000000001 x9 3a64889416988361 x10 3a64889416988361 x11 0000007f4f206a48
2019-07-17 15:19:51.988 23785-23785/? A/DEBUG: x12 0000000000000000 x13 2e6c61636f4c6562 x14 0000007f4f206a48 x15 0000000000005cc4
2019-07-17 15:19:51.988 23785-23785/? A/DEBUG: x16 0000007f2e6a2000 x17 0000007f2da5f494 x18 0000000000000000 x19 0000007f2e08316c
2019-07-17 15:19:51.988 23785-23785/? A/DEBUG: x20 0000007f2e083159 x21 0000007f392e7840 x22 0000007fda977f2c x23 0000007f4af7fd75
2019-07-17 15:19:51.988 23785-23785/? A/DEBUG: x24 000000000000000c x25 0000007f49ea7aa0 x26 0000000000000000 x27 0000000000000000
2019-07-17 15:19:51.988 23785-23785/? A/DEBUG: x28 0000007fda977c70 x29 0000007fda976ea0 x30 0000007f2cd066c8
2019-07-17 15:19:51.988 23785-23785/? A/DEBUG: sp 0000007fda976e80 pc 0000007f2da5f4ac pstate 0000000060000000
The backtrace's last two entries are my function which calls the script execution followed by v8::base::Abort()
If I remove the last line from the javascript, everything works fine.