Bug 53271

Summary: Potentially Unsafe HashSet of RuntimeObject* in RootObject definition
Product: WebKit Reporter: Michael Saboff <msaboff>
Component: WebCore JavaScriptAssignee: Michael Saboff <msaboff>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, alex, eric, ggaren, kevin, ossy, rhodes.unci, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: OS X 10.5   
Bug Depends on: 53287, 53418    
Bug Blocks:    
Attachments:
Description Flags
Patch to use WeakGCMap instead of HashSet in RootObject
none
Patch that addresses the test failures ggaren: review+

Description Michael Saboff 2011-01-27 17:15:27 PST
As part of investigating another defect, I came across the definition of
    HashSet<RuntimeObject*> m_runtimeObjects;
in RootOBject definition.

Since RuntimeObject's are GC'ed, there is the possibility that a RuntimeObject could be GC'ed but not removed from this HashSet.

Although I haven't determined a case where this is actually happening, it makes sense to make a preventative fix.
Comment 1 Michael Saboff 2011-01-27 18:05:47 PST
Created attachment 80391 [details]
Patch to use WeakGCMap instead of HashSet in RootObject
Comment 2 Michael Saboff 2011-01-27 18:18:26 PST
Committed r76893: <http://trac.webkit.org/changeset/76893>
Comment 3 WebKit Review Bot 2011-01-27 20:27:06 PST
http://trac.webkit.org/changeset/76893 might have broken GTK Linux 64-bit Debug
Comment 4 Csaba Osztrogonác 2011-01-28 00:58:40 PST
It made 460 tests crash on Qt debug bot: http://webkit.sed.hu/buildbot/results/x86-32%20Linux%20Qt%20Debug/r76893%20%2812399%29/results.html

ASSERTION FAILED: m_runtimeObjects.get(object)
(../../../Source/WebCore/bridge/runtime_root.cpp:189 void JSC::Bindings::RootObject::removeRuntimeObject(JSC::Bindings::RuntimeObject*))
Segmentation fault
Comment 5 Csaba Osztrogonác 2011-01-28 00:59:06 PST
Comment on attachment 80391 [details]
Patch to use WeakGCMap instead of HashSet in RootObject

remove r+ from landed patch
Comment 6 Csaba Osztrogonác 2011-01-28 01:11:56 PST
It was rolled out: http://trac.webkit.org/changeset/76925
Comment 7 Geoffrey Garen 2011-01-28 10:11:08 PST
+ ASSERT(m_runtimeObjects.get(object)); 

I think this needs to be "ASSERT(m_runtimeObjects.uncheckedGet(object))". By the time removeRuntimeObject is called, object is unmarked, so get will return 0.
Comment 8 Michael Saboff 2011-01-28 12:10:51 PST
Created attachment 80478 [details]
Patch that addresses the test failures

Made the change suggested by Geoff and successfully ran all tests in debug mode.
Comment 9 Geoffrey Garen 2011-01-28 12:15:32 PST
Comment on attachment 80478 [details]
Patch that addresses the test failures

r=me
Comment 10 Michael Saboff 2011-01-28 12:21:33 PST
Committed r76969: <http://trac.webkit.org/changeset/76969>
Comment 11 Alejandro G. Castro 2011-01-31 04:12:54 PST
(In reply to comment #10)
> Committed r76969: <http://trac.webkit.org/changeset/76969>

Apparently this could be still causing issues at least in GTK and Leopard Intel Debug, first crash in the compilation after that commit:

http://build.webkit.org/results/Leopard%20Intel%20Debug%20(Tests)/r76969%20(26725)/results.html

In Gtk+ we have the same assertions but they are flaky:

http://build.webkit.org/results/GTK%20Linux%2064-bit%20Debug/r77114%20(18774)/fast/frames/sandboxed-iframe-scripting-stderr.txt

Unfourtunately I can not reproduce it locally in gtk+. I'm going to rollout until you have time to check it.
Comment 12 Michael Saboff 2011-01-31 14:42:42 PST
*** Bug 53376 has been marked as a duplicate of this bug. ***
Comment 13 Eric Seidel (no email) 2011-02-02 14:24:07 PST
I'm seeing crashes relating to this on the Snow Leopard Debug bot:
http://build.webkit.org/results/SnowLeopard%20Intel%20Leaks/r77400%20(14522)/fast/events/tabindex-focus-blur-all-stderr.txt
Comment 14 Eric Seidel (no email) 2011-02-02 14:24:23 PST
SUCCESS: Build 14472 (r77164) was the first to show failures: set([u'fast/events/tabindex-focus-blur-all.html'])
Comment 15 Gavin Barraclough 2012-03-08 16:59:37 PST
*** Bug 53411 has been marked as a duplicate of this bug. ***