<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>82882</bug_id>
          
          <creation_ts>2012-04-02 04:16:39 -0700</creation_ts>
          <short_desc>[GTK] Invalid read from WebKit::DOMObjectCache::clearByFrame</short_desc>
          <delta_ts>2012-10-18 16:07:11 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebKitGTK</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Milan Crha">mcrha</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>darin</cc>
    
    <cc>David.Ronis</cc>
    
    <cc>webkit.review.bot</cc>
    
    <cc>xan.lopez</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>593336</commentid>
    <comment_count>0</comment_count>
    <who name="Milan Crha">mcrha</who>
    <bug_when>2012-04-02 04:16:39 -0700</bug_when>
    <thetext>I run Evolution under valgrind today, and because it adapted WebkitGtk as its mailer renderer, I observed these valgrind warnings (see below). This is with webkitgtk-1.8.0 tarball release.

The first is when opening a message in a separate window in evolution (double click in a message list).
The second is when closing the message window.

==3268== Thread 1:
==3268== Invalid read of size 4
==3268== at 0x7E93DF0: WebKit::DOMObjectCache::clearByFrame(WebCore::Frame*) (in /build/local/lib/libwebkitgtk-3.0.so.0.13.1)
==3268== by 0x83ED832: WebCore::FrameLoader::commitProvisionalLoad() (in /build/local/lib/libwebkitgtk-3.0.so.0.13.1)
==3268== by 0x83D7819: WebCore::DocumentLoader::commitLoad(char const*, int) (in /build/local/lib/libwebkitgtk-3.0.so.0.13.1)
==3268== by 0x841F027: WebCore::ResourceLoader::didReceiveData(char const*, int, long long, bool) (in /build/local/lib/libwebkitgtk-3.0.so.0.13.1)
==3268== by 0x840A4D4: WebCore::MainResourceLoader::didReceiveData(char const*, int, long long, bool) (in /build/local/lib/libwebkitgtk-3.0.so.0.13.1)
==3268== by 0x841E4DD: WebCore::ResourceLoader::didReceiveData(WebCore::ResourceHandle*, char const*, int, int) (in /build/local/lib/libwebkitgtk-3.0.so.0.13.1)
==3268== by 0x8546E19: WebCore::readCallback(_GObject*, _GAsyncResult*, void*) (in /build/local/lib/libwebkitgtk-3.0.so.0.13.1)
==3268== by 0xA3A37F0: async_ready_callback_wrapper (ginputstream.c:470)
==3268== by 0xA3BBB7A: g_simple_async_result_complete (gsimpleasyncresult.c:767)
==3268== by 0xA3BBBAC: complete_in_idle_cb (gsimpleasyncresult.c:779)
==3268== by 0xAD76800: g_idle_dispatch (gmain.c:4634)
==3268== by 0xAD740AA: g_main_dispatch (gmain.c:2515)
==3268== by 0xAD74D6B: g_main_context_dispatch (gmain.c:3052)
==3268== by 0xAD74F4E: g_main_context_iterate (gmain.c:3123)
==3268== by 0xAD75377: g_main_loop_run (gmain.c:3317)
==3268== by 0x39E4F517FC: gtk_main (gtkmain.c:1362)
==3268== by 0x403603: main (main.c:681)
==3268== Address 0x34bfb760 is 16 bytes inside a block of size 24 free&apos;d
==3268== at 0x4A0662E: free (vg_replace_malloc.c:366)
==3268== by 0xAD7C332: standard_free (gmem.c:98)
==3268== by 0xAD7C4F5: g_free (gmem.c:252)
==3268== by 0xAD945D7: g_slice_free1 (gslice.c:1111)
==3268== by 0x7E93FD7: WebKit::DOMObjectCache::forget(void*) (in /build/local/lib/libwebkitgtk-3.0.so.0.13.1)
==3268== by 0x7EE1DA9: webkit_dom_document_finalize(_GObject*) (in /build/local/lib/libwebkitgtk-3.0.so.0.13.1)
==3268== by 0xA8EA32C: g_object_unref (gobject.c:3018)
==3268== by 0x7E93E20: WebKit::DOMObjectCache::clearByFrame(WebCore::Frame*) (in /build/local/lib/libwebkitgtk-3.0.so.0.13.1)
==3268== by 0x83ED832: WebCore::FrameLoader::commitProvisionalLoad() (in /build/local/lib/libwebkitgtk-3.0.so.0.13.1)
==3268== by 0x83D7819: WebCore::DocumentLoader::commitLoad(char const*, int) (in /build/local/lib/libwebkitgtk-3.0.so.0.13.1)
==3268== by 0x841F027: WebCore::ResourceLoader::didReceiveData(char const*, int, long long, bool) (in /build/local/lib/libwebkitgtk-3.0.so.0.13.1)
==3268== by 0x840A4D4: WebCore::MainResourceLoader::didReceiveData(char const*, int, long long, bool) (in /build/local/lib/libwebkitgtk-3.0.so.0.13.1)
==3268== by 0x841E4DD: WebCore::ResourceLoader::didReceiveData(WebCore::ResourceHandle*, char const*, int, int) (in /build/local/lib/libwebkitgtk-3.0.so.0.13.1)
==3268== by 0x8546E19: WebCore::readCallback(_GObject*, _GAsyncResult*, void*) (in /build/local/lib/libwebkitgtk-3.0.so.0.13.1)
==3268== by 0xA3A37F0: async_ready_callback_wrapper (ginputstream.c:470)
==3268== by 0xA3BBB7A: g_simple_async_result_complete (gsimpleasyncresult.c:767)
==3268== by 0xA3BBBAC: complete_in_idle_cb (gsimpleasyncresult.c:779)
==3268== by 0xAD76800: g_idle_dispatch (gmain.c:4634)
==3268== by 0xAD740AA: g_main_dispatch (gmain.c:2515)
==3268== by 0xAD74D6B: g_main_context_dispatch (gmain.c:3052)
==3268== by 0xAD74F4E: g_main_context_iterate (gmain.c:3123)
==3268== by 0xAD75377: g_main_loop_run (gmain.c:3317)
==3268== by 0x39E4F517FC: gtk_main (gtkmain.c:1362)
==3268== by 0x403603: main (main.c:681)
 
 
==3268== Invalid read of size 4
==3268== at 0x7E93DF0: WebKit::DOMObjectCache::clearByFrame(WebCore::Frame*) (in /build/local/lib/libwebkitgtk-3.0.so.0.13.1)
==3268== by 0x7EBC301: webkit_web_frame_core_frame_gone (in /build/local/lib/libwebkitgtk-3.0.so.0.13.1)
==3268== by 0x7EA44CC: WebKit::FrameLoaderClient::frameLoaderDestroyed() (in /build/local/lib/libwebkitgtk-3.0.so.0.13.1)
==3268== by 0x83E9B61: WebCore::FrameLoader::~FrameLoader() (in /build/local/lib/libwebkitgtk-3.0.so.0.13.1)
==3268== by 0x8478F3B: WebCore::Frame::~Frame() (in /build/local/lib/libwebkitgtk-3.0.so.0.13.1)
==3268== by 0x84963EB: WebCore::Page::~Page() (in /build/local/lib/libwebkitgtk-3.0.so.0.13.1)
==3268== by 0x7ED1347: webkit_web_view_dispose(_GObject*) (in /build/local/lib/libwebkitgtk-3.0.so.0.13.1)
==3268== by 0x57F8A16: web_view_dispose (e-web-view.c:796)
==3268== by 0x1682BAB6: mail_display_dispose (e-mail-display.c:318)
==3268== by 0xA8E52B9: g_object_run_dispose (gobject.c:1061)
==3268== by 0x39E4FB2E7D: gtk_scrolled_window_forall (gtkscrolledwindow.c:1265)
==3268== by 0x39E4ECE1CA: gtk_container_destroy (gtkcontainer.c:1370)
==3268== by 0xA8E10A3: g_cclosure_marshal_VOID__VOID (gmarshal.c:85)
==3268== by 0xA8DE7C8: g_type_class_meta_marshal (gclosure.c:970)
==3268== by 0xA8DE113: g_closure_invoke (gclosure.c:777)
==3268== by 0xA8FAAE4: signal_emit_unlocked_R (gsignal.c:3663)
==3268== by 0xA8F9966: g_signal_emit_valist (gsignal.c:3296)
==3268== by 0xA8F9EAC: g_signal_emit (gsignal.c:3352)
==3268== by 0x39E50895CD: gtk_widget_dispose (gtkwidget.c:10666)
==3268== by 0xA8E52B9: g_object_run_dispose (gobject.c:1061)
==3268== by 0x39E4E8B923: gtk_box_forall (gtkbox.c:1856)
==3268== by 0x39E4ECE1CA: gtk_container_destroy (gtkcontainer.c:1370)
==3268== by 0xA8E10A3: g_cclosure_marshal_VOID__VOID (gmarshal.c:85)
==3268== by 0xA8DE7C8: g_type_class_meta_marshal (gclosure.c:970)
==3268== by 0xA8DE113: g_closure_invoke (gclosure.c:777)
==3268== by 0xA8FAAE4: signal_emit_unlocked_R (gsignal.c:3663)
==3268== by 0xA8F9966: g_signal_emit_valist (gsignal.c:3296)
==3268== by 0xA8F9EAC: g_signal_emit (gsignal.c:3352)
==3268== by 0x39E50895CD: gtk_widget_dispose (gtkwidget.c:10666)
==3268== by 0x57E6783: preview_pane_dispose (e-preview-pane.c:143)
==3268== by 0xA8E52B9: g_object_run_dispose (gobject.c:1061)
==3268== by 0x39E4E8B923: gtk_box_forall (gtkbox.c:1856)
==3268== by 0x39E4ECE1CA: gtk_container_destroy (gtkcontainer.c:1370)
==3268== by 0xA8E10A3: g_cclosure_marshal_VOID__VOID (gmarshal.c:85)
==3268== by 0xA8DE7C8: g_type_class_meta_marshal (gclosure.c:970)
==3268== by 0xA8DE113: g_closure_invoke (gclosure.c:777)
==3268== by 0xA8FAAE4: signal_emit_unlocked_R (gsignal.c:3663)
==3268== by 0xA8F9966: g_signal_emit_valist (gsignal.c:3296)
==3268== by 0xA8F9EAC: g_signal_emit (gsignal.c:3352)
==3268== by 0x39E50895CD: gtk_widget_dispose (gtkwidget.c:10666)
==3268== by 0xA8E52B9: g_object_run_dispose (gobject.c:1061)
==3268== by 0x39E4ECE1CA: gtk_container_destroy (gtkcontainer.c:1370)
==3268== by 0xA8E10A3: g_cclosure_marshal_VOID__VOID (gmarshal.c:85)
==3268== by 0xA8DE7C8: g_type_class_meta_marshal (gclosure.c:970)
==3268== by 0xA8DE113: g_closure_invoke (gclosure.c:777)
==3268== by 0xA8FAAE4: signal_emit_unlocked_R (gsignal.c:3663)
==3268== by 0xA8F9966: g_signal_emit_valist (gsignal.c:3296)
==3268== by 0xA8F9EAC: g_signal_emit (gsignal.c:3352)
==3268== by 0x39E50895CD: gtk_widget_dispose (gtkwidget.c:10666)
==3268== by 0x16829FAD: mail_browser_dispose (e-mail-browser.c:533)
==3268== Address 0x1bebfa10 is 16 bytes inside a block of size 24 free&apos;d
==3268== at 0x4A0662E: free (vg_replace_malloc.c:366)
==3268== by 0xAD7C332: standard_free (gmem.c:98)
==3268== by 0xAD7C4F5: g_free (gmem.c:252)
==3268== by 0xAD945D7: g_slice_free1 (gslice.c:1111)
==3268== by 0x7E93FD7: WebKit::DOMObjectCache::forget(void*) (in /build/local/lib/libwebkitgtk-3.0.so.0.13.1)
==3268== by 0x7EE1DA9: webkit_dom_document_finalize(_GObject*) (in /build/local/lib/libwebkitgtk-3.0.so.0.13.1)
==3268== by 0xA8EA32C: g_object_unref (gobject.c:3018)
==3268== by 0x7E93E20: WebKit::DOMObjectCache::clearByFrame(WebCore::Frame*) (in /build/local/lib/libwebkitgtk-3.0.so.0.13.1)
==3268== by 0x7EBC301: webkit_web_frame_core_frame_gone (in /build/local/lib/libwebkitgtk-3.0.so.0.13.1)
==3268== by 0x7EA44CC: WebKit::FrameLoaderClient::frameLoaderDestroyed() (in /build/local/lib/libwebkitgtk-3.0.so.0.13.1)
==3268== by 0x83E9B61: WebCore::FrameLoader::~FrameLoader() (in /build/local/lib/libwebkitgtk-3.0.so.0.13.1)
==3268== by 0x8478F3B: WebCore::Frame::~Frame() (in /build/local/lib/libwebkitgtk-3.0.so.0.13.1)
==3268== by 0x84963EB: WebCore::Page::~Page() (in /build/local/lib/libwebkitgtk-3.0.so.0.13.1)
==3268== by 0x7ED1347: webkit_web_view_dispose(_GObject*) (in /build/local/lib/libwebkitgtk-3.0.so.0.13.1)
==3268== by 0x57F8A16: web_view_dispose (e-web-view.c:796)
==3268== by 0x1682BAB6: mail_display_dispose (e-mail-display.c:318)
==3268== by 0xA8E52B9: g_object_run_dispose (gobject.c:1061)
==3268== by 0x39E4FB2E7D: gtk_scrolled_window_forall (gtkscrolledwindow.c:1265)
==3268== by 0x39E4ECE1CA: gtk_container_destroy (gtkcontainer.c:1370)
==3268== by 0xA8E10A3: g_cclosure_marshal_VOID__VOID (gmarshal.c:85)
==3268== by 0xA8DE7C8: g_type_class_meta_marshal (gclosure.c:970)
==3268== by 0xA8DE113: g_closure_invoke (gclosure.c:777)
==3268== by 0xA8FAAE4: signal_emit_unlocked_R (gsignal.c:3663)
==3268== by 0xA8F9966: g_signal_emit_valist (gsignal.c:3296)
==3268== by 0xA8F9EAC: g_signal_emit (gsignal.c:3352)
==3268== by 0x39E50895CD: gtk_widget_dispose (gtkwidget.c:10666)
==3268== by 0xA8E52B9: g_object_run_dispose (gobject.c:1061)
==3268== by 0x39E4E8B923: gtk_box_forall (gtkbox.c:1856)
==3268== by 0x39E4ECE1CA: gtk_container_destroy (gtkcontainer.c:1370)
==3268== by 0xA8E10A3: g_cclosure_marshal_VOID__VOID (gmarshal.c:85)
==3268== by 0xA8DE7C8: g_type_class_meta_marshal (gclosure.c:970)
==3268== by 0xA8DE113: g_closure_invoke (gclosure.c:777)
==3268== by 0xA8FAAE4: signal_emit_unlocked_R (gsignal.c:3663)
==3268== by 0xA8F9966: g_signal_emit_valist (gsignal.c:3296)
==3268== by 0xA8F9EAC: g_signal_emit (gsignal.c:3352)
==3268== by 0x39E50895CD: gtk_widget_dispose (gtkwidget.c:10666)
==3268== by 0x57E6783: preview_pane_dispose (e-preview-pane.c:143)
==3268== by 0xA8E52B9: g_object_run_dispose (gobject.c:1061)
==3268== by 0x39E4E8B923: gtk_box_forall (gtkbox.c:1856)
==3268== by 0x39E4ECE1CA: gtk_container_destroy (gtkcontainer.c:1370)
==3268== by 0xA8E10A3: g_cclosure_marshal_VOID__VOID (gmarshal.c:85)
==3268== by 0xA8DE7C8: g_type_class_meta_marshal (gclosure.c:970)
==3268== by 0xA8DE113: g_closure_invoke (gclosure.c:777)
==3268== by 0xA8FAAE4: signal_emit_unlocked_R (gsignal.c:3663)
==3268== by 0xA8F9966: g_signal_emit_valist (gsignal.c:3296)
==3268== by 0xA8F9EAC: g_signal_emit (gsignal.c:3352)
==3268== by 0x39E50895CD: gtk_widget_dispose (gtkwidget.c:10666)
==3268== by 0xA8E52B9: g_object_run_dispose (gobject.c:1061)
==3268== by 0x39E4ECE1CA: gtk_container_destroy (gtkcontainer.c:1370)
==3268== by 0xA8E10A3: g_cclosure_marshal_VOID__VOID (gmarshal.c:85)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>593339</commentid>
    <comment_count>1</comment_count>
      <attachid>135063</attachid>
    <who name="Milan Crha">mcrha</who>
    <bug_when>2012-04-02 04:24:12 -0700</bug_when>
    <thetext>Created attachment 135063
proposed webkit patch

for webkit;

Basically, if everything goes correctly then the weakRefNotify() is never called, thus objectDead is always FALSE, thus the &apos;while&apos; dereferences the &apos;data&apos; which is already freed in the last loop cycle. I tested with valgrind and it is happy with this patch included.

Just for a reference, here&apos;s the code I talk about (without patch applied):

        gboolean objectDead = FALSE;
        g_object_weak_ref(data-&gt;object, weakRefNotify, &amp;objectDead);
        // We need to check objectDead first, otherwise the cache data
        // might be garbage already.
        while (!objectDead &amp;&amp; data-&gt;timesReturned &gt; 0) {
            // If this is the last unref we are going to do,
            // disconnect the weak ref. We cannot do it afterwards
            // because the object might be dead at that point.
            if (data-&gt;timesReturned == 1)
                g_object_weak_unref(data-&gt;object, weakRefNotify, &amp;objectDead);
            data-&gt;timesReturned--;
            g_object_unref(data-&gt;object);
        }</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>638426</commentid>
    <comment_count>2</comment_count>
    <who name="WebKit Review Bot">webkit.review.bot</who>
    <bug_when>2012-05-31 08:10:32 -0700</bug_when>
    <thetext>Attachment 135063 did not pass style-queue:

Failed to run &quot;[&apos;Tools/Scripts/check-webkit-style&apos;, &apos;--diff-files&apos;]&quot; exit_code: 1
Total errors found: 0 in 0 files


If any of these errors are false positives, please file a bug against check-webkit-style.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>702464</commentid>
    <comment_count>3</comment_count>
      <attachid>135063</attachid>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2012-08-22 15:44:34 -0700</bug_when>
    <thetext>Comment on attachment 135063
proposed webkit patch

Needs a ChangeLog.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>702735</commentid>
    <comment_count>4</comment_count>
    <who name="Milan Crha">mcrha</who>
    <bug_when>2012-08-22 23:42:17 -0700</bug_when>
    <thetext>Are you kidding me? This almost two-liner fixes not-so-obvious error in the code which is still there in 1.9.6, waiting for a review for almost 5 months, and you reject it because of missing ChangeLog? Come on...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>744145</commentid>
    <comment_count>5</comment_count>
    <who name="Xan Lopez">xan.lopez</who>
    <bug_when>2012-10-17 04:39:17 -0700</bug_when>
    <thetext>(In reply to comment #4)
&gt; Are you kidding me? This almost two-liner fixes not-so-obvious error in the code which is still there in 1.9.6, waiting for a review for almost 5 months, and you reject it because of missing ChangeLog? Come on...

Writing a ChangeLog should be a matter of 5 minutes. If you don&apos;t do it someone else has to, I don&apos;t see what&apos;s so shocking about being strict in this regard.

About the patch, one question:

You mention &quot;if everything goes correctly the weakRefNotify is never called&quot;, because we disable it before doing the last unref. Right? In that same block we&apos;l decrease timesReturned, so while objectDead will still be FALSE timesReturned should be 0 (since we only do the last unref when it&apos;s 1). So we shouldn&apos;t really enter the loop again. I guess I&apos;m missing something because there&apos;s indeed a valgrind warning, so what am I getting wrong?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>745026</commentid>
    <comment_count>6</comment_count>
    <who name="Milan Crha">mcrha</who>
    <bug_when>2012-10-18 00:03:21 -0700</bug_when>
    <thetext>(In reply to comment #5)
&gt; (In reply to comment #4)
&gt; &gt; Are you kidding me? This almost two-liner fixes not-so-obvious error in the code which is still there in 1.9.6, waiting for a review for almost 5 months, and you reject it because of missing ChangeLog? Come on...
&gt; 
&gt; Writing a ChangeLog should be a matter of 5 minutes. If you don&apos;t do it someone else has to, I don&apos;t see what&apos;s so shocking about being strict in this regard.

It&apos;s &quot;shocking&quot; when asked doing so after 5 months of waiting for a review. I moved quite far away from this during those 5 months.

&gt; About the patch, one question:
&gt; 
&gt; You mention &quot;if everything goes correctly the weakRefNotify is never called&quot;, because we disable it before doing the last unref. Right?

You didn&apos;t quote the right passage of the explanation from comment #1. (See below.)

&gt; In that same block we&apos;l decrease timesReturned, so while objectDead will still be FALSE timesReturned should be 0 (since we only do the last unref when it&apos;s 1). So we shouldn&apos;t really enter the loop again. I guess I&apos;m missing something because there&apos;s indeed a valgrind warning, so what am I getting wrong?

That&apos;s what I thought about this too, the issue is not obvious on the first look.

The issue is not with g_object_unref() call, valgrind doesn&apos;t claim on it, the issue is with the &apos;data&apos; structure, which is freed together with data-&gt;object. Following your &apos;while&apos; steps (see code in comment #1) it&apos;s like this:
   : let data-&gt;timesReturned be 1
   : objectDead is FALSE
   the g_object_weak_unref() is called
   data-&gt;timesReturned is decreased to 0
   g_object_unref() is called
   : so far so good, &apos;data-&gt;object&apos; is freed,
   : together with &apos;data&apos; itself, but objectDead is still FALSE
   : then it comes to the &apos;while&apos; clause
   while (!objectDead &amp;&amp; data-&gt;timesReturned &gt; 0)
   : and because objectDead is FALSE, and &apos;data&apos; is freed, then it dereferences freed memory</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>745112</commentid>
    <comment_count>7</comment_count>
    <who name="Xan Lopez">xan.lopez</who>
    <bug_when>2012-10-18 02:56:58 -0700</bug_when>
    <thetext>(In reply to comment #6)
&gt; The issue is not with g_object_unref() call, valgrind doesn&apos;t claim on it, the issue is with the &apos;data&apos; structure, which is freed together with data-&gt;object. Following your &apos;while&apos; steps (see code in comment #1) it&apos;s like this:
&gt;    : let data-&gt;timesReturned be 1
&gt;    : objectDead is FALSE
&gt;    the g_object_weak_unref() is called
&gt;    data-&gt;timesReturned is decreased to 0
&gt;    g_object_unref() is called
&gt;    : so far so good, &apos;data-&gt;object&apos; is freed,
&gt;    : together with &apos;data&apos; itself, but objectDead is still FALSE
&gt;    : then it comes to the &apos;while&apos; clause
&gt;    while (!objectDead &amp;&amp; data-&gt;timesReturned &gt; 0)
&gt;    : and because objectDead is FALSE, and &apos;data&apos; is freed, then it dereferences freed memory

Ah, indeed. &apos;data&apos; is freed in the object&apos;s ::finalize, which calls the DOMObjectCache function &apos;forget&apos;. Tricky.

So I think the patch is OK, but I&apos;d put an extra comment explaining what&apos;s going on here, since it&apos;s not really trivial to see. If you can do that plus a ChangeLog I&apos;ll be happy to r+, thanks a lot for figuring this out.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>745309</commentid>
    <comment_count>8</comment_count>
    <who name="Milan Crha">mcrha</who>
    <bug_when>2012-10-18 09:09:46 -0700</bug_when>
    <thetext>I&apos;m afraid it&apos;s as hard to spot as to explain, at least in a comment in the code. I would do the ChangeLog, but I do not have checkout of webkit handy, I really moved elsewhere between those 5 months. I&apos;m sorry.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>745642</commentid>
    <comment_count>9</comment_count>
      <attachid>169489</attachid>
    <who name="Claudio Saavedra">csaavedra</who>
    <bug_when>2012-10-18 15:33:35 -0700</bug_when>
    <thetext>Created attachment 169489
2012-10-18  Claudio Saavedra  &lt;csaavedra@igalia.com&gt;

[GTK] Invalid read from WebKit::DOMObjectCache::clearByFrame
        https://bugs.webkit.org/show_bug.cgi?id=82882

        Reviewed by NOBODY (OOPS!).

        Based on a patch by Milan Crha &lt;mcrha@redhat.com&gt;

        Prevent an invalid access to a pointer while clearing the DOM
        object cache.
        * bindings/gobject/DOMObjectCache.cpp:
        (WebKit::DOMObjectCache::clearByFrame): Prevent an invalid access.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>745650</commentid>
    <comment_count>10</comment_count>
      <attachid>169489</attachid>
    <who name="Xan Lopez">xan.lopez</who>
    <bug_when>2012-10-18 15:37:09 -0700</bug_when>
    <thetext>Comment on attachment 169489
2012-10-18  Claudio Saavedra  &lt;csaavedra@igalia.com&gt;

Looks good, thank you.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>745695</commentid>
    <comment_count>11</comment_count>
      <attachid>169489</attachid>
    <who name="WebKit Review Bot">webkit.review.bot</who>
    <bug_when>2012-10-18 16:07:07 -0700</bug_when>
    <thetext>Comment on attachment 169489
2012-10-18  Claudio Saavedra  &lt;csaavedra@igalia.com&gt;

Clearing flags on attachment: 169489

Committed r131820: &lt;http://trac.webkit.org/changeset/131820&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>745696</commentid>
    <comment_count>12</comment_count>
    <who name="WebKit Review Bot">webkit.review.bot</who>
    <bug_when>2012-10-18 16:07:11 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>135063</attachid>
            <date>2012-04-02 04:24:12 -0700</date>
            <delta_ts>2012-08-22 15:44:33 -0700</delta_ts>
            <desc>proposed webkit patch</desc>
            <filename>wk.patch</filename>
            <type>text/plain</type>
            <size>934</size>
            <attacher name="Milan Crha">mcrha</attacher>
            
              <data encoding="base64">ZGlmZiAtdXAgd2Via2l0LTEuOC4wL1NvdXJjZS9XZWJDb3JlL2JpbmRpbmdzL2dvYmplY3QvRE9N
T2JqZWN0Q2FjaGUuY3BwLmludmFsaWQtcmVhZCB3ZWJraXQtMS44LjAvU291cmNlL1dlYkNvcmUv
YmluZGluZ3MvZ29iamVjdC9ET01PYmplY3RDYWNoZS5jcHAKLS0tIHdlYmtpdC0xLjguMC9Tb3Vy
Y2UvV2ViQ29yZS9iaW5kaW5ncy9nb2JqZWN0L0RPTU9iamVjdENhY2hlLmNwcC5pbnZhbGlkLXJl
YWQJMjAxMi0wNC0wMiAxMzowMzowOS4yODU0OTgxNzIgKzAyMDAKKysrIHdlYmtpdC0xLjguMC9T
b3VyY2UvV2ViQ29yZS9iaW5kaW5ncy9nb2JqZWN0L0RPTU9iamVjdENhY2hlLmNwcAkyMDEyLTA0
LTAyIDEzOjAzOjIwLjAwODYzMzQzOSArMDIwMApAQCAtOTcsOCArOTcsMTAgQEAgdm9pZCBET01P
YmplY3RDYWNoZTo6Y2xlYXJCeUZyYW1lKFdlYkNvcgogICAgICAgICAgICAgLy8gSWYgdGhpcyBp
cyB0aGUgbGFzdCB1bnJlZiB3ZSBhcmUgZ29pbmcgdG8gZG8sCiAgICAgICAgICAgICAvLyBkaXNj
b25uZWN0IHRoZSB3ZWFrIHJlZi4gV2UgY2Fubm90IGRvIGl0IGFmdGVyd2FyZHMKICAgICAgICAg
ICAgIC8vIGJlY2F1c2UgdGhlIG9iamVjdCBtaWdodCBiZSBkZWFkIGF0IHRoYXQgcG9pbnQuCi0g
ICAgICAgICAgICBpZiAoZGF0YS0+dGltZXNSZXR1cm5lZCA9PSAxKQorICAgICAgICAgICAgaWYg
KGRhdGEtPnRpbWVzUmV0dXJuZWQgPT0gMSkgewogICAgICAgICAgICAgICAgIGdfb2JqZWN0X3dl
YWtfdW5yZWYoZGF0YS0+b2JqZWN0LCB3ZWFrUmVmTm90aWZ5LCAmb2JqZWN0RGVhZCk7CisgICAg
ICAgICAgICAgICAgb2JqZWN0RGVhZCA9IFRSVUU7CisgICAgICAgICAgICB9CiAgICAgICAgICAg
ICBkYXRhLT50aW1lc1JldHVybmVkLS07CiAgICAgICAgICAgICBnX29iamVjdF91bnJlZihkYXRh
LT5vYmplY3QpOwogICAgICAgICB9Cg==
</data>
<flag name="review"
          id="152139"
          type_id="1"
          status="-"
          setter="eric"
    />
          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>169489</attachid>
            <date>2012-10-18 15:33:35 -0700</date>
            <delta_ts>2012-10-18 16:07:07 -0700</delta_ts>
            <desc>2012-10-18  Claudio Saavedra  &lt;csaavedra@igalia.com&gt;</desc>
            <filename>2012-10-18-Claudio-Saavedra-csaavedraigaliacom.patch</filename>
            <type>text/plain</type>
            <size>2921</size>
            <attacher name="Claudio Saavedra">csaavedra</attacher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vaW50LCB0aGUgbmV4dCB0aW1lIHRoZSBET01PYmplY3QgaXMKKyAgICAgICAgICAgICAgICAv
LyB1bnJlZidlZCBpdCB3aWxsIGJlIGZpbmFsaXplZCwKKyAgICAgICAgICAgICAgICAvLyBET01P
YmplY3Q6OmZpbmFsaXplKCkgd2lsbCBjYWxsCisgICAgICAgICAgICAgICAgLy8gRE9NT2JqZWN0
Q2FjaGU6OmZvcmdldCgpLCB3aGljaCB3aWxsIGZyZWUgJ2RhdGEnLgorICAgICAgICAgICAgICAg
IC8vIFRvZ2dsaW5nICdvYmplY3REZWFkJyBoZXJlIHdpbGwgZW5zdXJlIHdlIGRvbid0CisgICAg
ICAgICAgICAgICAgLy8gZGVyZWZlcmVuY2UgYW4gaW52YWxpZCBwb2ludGVyIGluIHRoZSBuZXh0
CisgICAgICAgICAgICAgICAgLy8gaXRlcmF0aW9uLgorICAgICAgICAgICAgICAgIG9iamVjdERl
YWQgPSBUUlVFOworICAgICAgICAgICAgfQogICAgICAgICAgICAgZGF0YS0+dGltZXNSZXR1cm5l
ZC0tOwogICAgICAgICAgICAgZ19vYmplY3RfdW5yZWYoZGF0YS0+b2JqZWN0KTsKICAgICAgICAg
fQotLSAKMS43LjExLjc=
</data>

          </attachment>
      

    </bug>

</bugzilla>