This is debug build, on release build, I am getting null pointer reference 
on `(void)f->Call(context, Undefined(isolate), 3, args);` this line, but f 
is not nullpointer as I debug.

On Sunday, June 14, 2020 at 9:20:36 PM UTC+8 techni...@gmail.com wrote:

> I am implementing a PromiseRejection hook for android. But when I upgrade 
> to v8 8.3. It crashes.
>
> logcat
>
> ```console
> 2020-06-14 21:14:12.690 28467-28517/org.hapjs.mockup E/v8: #
>     # Fatal error in ../../src/debug/debug.cc, line 2204
>     # 
> 2020-06-14 21:14:12.690 28467-28517/org.hapjs.mockup E/v8: Debug check 
> failed: isolate_->has_pending_exception().
> ```
>
> ```cpp
> void handle(PromiseRejectMessage message) {
> auto promise = message.GetPromise();
> auto event = message.GetEvent();
> auto value = message.GetValue();
>
> Isolate* isolate = promise->GetIsolate();
> Local<Context> context = isolate->GetCurrentContext();
> Local<String> quickApp =
> String::NewFromUtf8(isolate, "QuickApp", NewStringType::kNormal)
> .ToLocalChecked();
> Local<String> p =
> String::NewFromUtf8(isolate, "unhandledrejection", NewStringType::kNormal)
> .ToLocalChecked();
> v8::Local<v8::Object> global =
> context->Global()->GetPrototype().As<v8::Object>();
>
> v8::Local<v8::Value> quickAppGlobalMaybe;
> (void)global->Get(context, quickApp).ToLocal(&quickAppGlobalMaybe);
> if (quickAppGlobalMaybe.IsEmpty() || !quickAppGlobalMaybe->IsObject()) {
> return;
> }
>
> Local<v8::Object> quickAppGlobal = quickAppGlobalMaybe.As<Object>();
>
> v8::Local<v8::Value> rejectFunc;
> (void)quickAppGlobal->Get(context, p).ToLocal(&rejectFunc);
>
> if (rejectFunc->IsFunction()) {
> Local<Function> f = rejectFunc.As<Function>();
> Local<Value> type = Number::New(isolate, event);
> Local<Value> args[] = {type, promise, value};
>
> // See https://github.com/nodejs/node/pull/29513
> if(value.IsEmpty()){
> value = v8::Undefined(isolate);
> }
> v8::TryCatch try_catch(isolate);
> (void)f->Call(context, Undefined(isolate), 3, args);
> if (try_catch.HasCaught() && !try_catch.HasTerminated()) {
> fprintf(stderr, "Exception in PromiseRejectCallback:\n");
> }
> }
> }
> ```
>
> Anyone can help me on this one, thanks.
>
>

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-users/be252979-8f28-4d4e-a800-40dce0d54832n%40googlegroups.com.

Reply via email to