Status: New
Owner: ----

New issue 2148 by [email protected]: Null(Isolate* isolate) crashes if we pass 0 for isolate
http://code.google.com/p/v8/issues/detail?id=2148

TL;DR We want to have Null(Isolate* isolate) check whether isolate is 0 or not. Please cc to Michael.

WebKit cannot always get Isolate when WebKit calls back V8 APIs. For example, in case where we dispatch an event handler from the context of WebCore, we do not know the current Isolate. To handle those cases beautifully, V8 binidings use an optional Isolate argument, like this:

Handle<Value> foo(..., Isolate* isolate = 0) {
    return Null(isolate);
}

We can call foo(isolate) if we can get the isolate, and we can call foo() if we cannot get the isolate.

The problem happens when we call foo(). It calls Null(0) and crashes. Of course, it is possible to fix the above code not to call Null(0), like this:

Handle<Value> foo(..., Isolate* isolate = 0) {
    return isolate ? Null(isolate) : Null();
}

but it is too dirty to write such code here and there in V8 bindings.

Would it be possible to insert the "if(isolate)" check into Null(isolate)? The same check would be desirable for Undefined(), True(), False() and String::Empty().

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to