Status: New
Owner: ----

New issue 1780 by [email protected]: API crash in LowMemoryNotification().
http://code.google.com/p/v8/issues/detail?id=1780

When putting recent v8 version into existing Android releases (Honeycomb, Ginger, Froyo) an apk which opens a webview (such as 0xbench) causes a crash in v8, in api call v8::V8::LowMemoryNotification().

Webkit calls this API before v8 is initialized, and therefore it has no current isolate, and we NULL de-reference.

void v8::V8::LowMemoryNotification() {
  i::Isolate* isolate = i::Isolate::Current();
  if (!isolate->IsInitialized()) return;
  isolate->heap()->CollectAllAvailableGarbage();
}

I suspect this is an API violation, however, it does seem a bit fragile. Prior to introduction of isolates, this was no problem as IsRunning() just checked a static variable:

void v8::V8::LowMemoryNotification() {
  if (!i::V8::IsRunning()) return;
  i::Heap::CollectAllGarbage(true);
}

An easy solution is this:

diff --git a/src/api.cc b/src/api.cc
index e2d0b49..00b1de4 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -4009,7 +4009,7 @@ bool v8::V8::IdleNotification() {

 void v8::V8::LowMemoryNotification() {
   i::Isolate* isolate = i::Isolate::Current();
-  if (!isolate->IsInitialized()) return;
+  if (!isolate || !isolate->IsInitialized()) return;
   isolate->heap()->CollectAllGarbage(true);
 }


This idiom 'if (!isolate->IsInitialized())' does appear in many places in the api, and if you think it should be fixed, it should probably be fixed everywhere.

You can get the 0xbench app here: http://code.google.com/p/0xbench/


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

Reply via email to