RESOLVED FIXED 94899
[V8] StringCache should not return already disposed string
https://bugs.webkit.org/show_bug.cgi?id=94899
Summary [V8] StringCache should not return already disposed string
Kentaro Hara
Reported 2012-08-23 22:37:42 PDT
See this Chromium bug (http://code.google.com/p/chromium/issues/detail?id=143937) for details. I investigated the crash and found that v8ExternalString() can return already disposed strings: class StringCache { v8::Local<v8::String> v8ExternalString(StringImpl* stringImpl, v8::Isolate* isolate) { if (m_lastStringImpl.get() == stringImpl) { ASSERT(!m_lastV8String.IsNearDeath()); ASSERT(!m_lastV8String.IsEmpty()); return v8::Local<v8::String>::New(m_lastV8String); // m_lastV8String might be already Disposed. } return v8ExternalStringSlow(stringImpl, isolate); } } I couldn't find why m_lastV8String can be prematurely disposed, but the following fix will solve the crash: class StringCache { v8::Local<v8::String> v8ExternalString(StringImpl* stringImpl, v8::Isolate* isolate) { if (m_lastStringImpl.get() == stringImpl && m_lastV8String.IsWeak()) return v8::Local<v8::String>::New(m_lastV8String); return v8ExternalStringSlow(stringImpl, isolate); } } Although the ideal fix might be to fix the root cause of the premature disposal, I think that the above fix is reasonable for safety. In fact, we've so far encountered crashes caused by premature disposals (e.g. r123500). The above fix will prevent future crashes caused by premature disposals.
Attachments
Patch (4.08 KB, patch)
2012-08-23 22:42 PDT, Kentaro Hara
no flags
Kentaro Hara
Comment 1 2012-08-23 22:42:57 PDT
Adam Barth
Comment 2 2012-08-23 22:57:43 PDT
Comment on attachment 160330 [details] Patch Ok. This feels a bit like papering over the problem though.
WebKit Review Bot
Comment 3 2012-08-23 23:41:24 PDT
Comment on attachment 160330 [details] Patch Clearing flags on attachment: 160330 Committed r126547: <http://trac.webkit.org/changeset/126547>
WebKit Review Bot
Comment 4 2012-08-23 23:41:27 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.