<?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>182271</bug_id>
          
          <creation_ts>2018-01-29 17:22:33 -0800</creation_ts>
          <short_desc>[WPE][GTK] Make RunLoop::TimerBase robust to its own deletion inside its source callback</short_desc>
          <delta_ts>2018-02-01 11:41:17 -0800</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>Other</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=182365</see_also>
          <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>1</everconfirmed>
          <reporter name="Michael Catanzaro">mcatanzaro</reporter>
          <assigned_to name="Michael Catanzaro">mcatanzaro</assigned_to>
          <cc>benjamin</cc>
    
    <cc>bugs-noreply</cc>
    
    <cc>cdumez</cc>
    
    <cc>cgarcia</cc>
    
    <cc>cmarcelo</cc>
    
    <cc>dbates</cc>
    
    <cc>ews-watchlist</cc>
    
    <cc>mcatanzaro</cc>
    
    <cc>rniwa</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1394352</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2018-01-29 17:22:33 -0800</bug_when>
    <thetext>This error occurs 100% when starting GTK MiniBrowser. You just need to wait a few seconds after page load completes. The problem is surely that the RunLoop::Timer owned by the HysteresisActivity owned by SpeculativeLoadManager::PendingFrameLoad has been destroyed already, yet its source callback (the lambda in its constructor) is executing anyway.

I think that should only be possible if it&apos;s created on one thread and destroyed on another, which would be unsafe. To verify, I tried adding a call to g_source_is_destroyed(g_main_current_source()) at the top of the callback, which I think should have &quot;fixed&quot; it if that was the problem, but it didn&apos;t, which surprised me. Then I added some asserts and confirmed that PendingFrameLoads are only used on the main thread. So that&apos;s not it. I&apos;m not sure what&apos;s going wrong, and I&apos;ve been staring at this for two hours now, so time to move on....

==21247==ERROR: AddressSanitizer: heap-use-after-free on address 0x611000005d68 at pc 0x7f7acd13c0fc bp 0x7fff70b96df0 sp 0x7fff70b96de0
READ of size 1 at 0x611000005d68 thread T0
    #0 0x7f7acd13c0fb in WTF::RunLoop::TimerBase::TimerBase(WTF::RunLoop&amp;)::{lambda(void*)#1}::operator()(void*) const (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18+0x4c8b0fb)
    #1 0x7f7acd13c137 in WTF::RunLoop::TimerBase::TimerBase(WTF::RunLoop&amp;)::{lambda(void*)#1}::_FUN(void*) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18+0x4c8b137)
    #2 0x7f7acd13b05f in WTF::{lambda(_GSource*, int (*)(void*), void*)#1}::operator()(_GSource*, int (*)(void*), void*) const (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18+0x4c8a05f)
    #3 0x7f7acd13b08e in WTF::{lambda(_GSource*, int (*)(void*), void*)#1}::_FUN(_GSource*, int (*)(void*), void*) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18+0x4c8a08e)
    #4 0x7f7ac20c57b4 in g_main_dispatch /home/mcatanzaro/Projects/WebKit/WebKitBuild/DependenciesGTK/Source/glib-2.54.2/glib/gmain.c:3148
    #5 0x7f7ac20c57b4 in g_main_context_dispatch /home/mcatanzaro/Projects/WebKit/WebKitBuild/DependenciesGTK/Source/glib-2.54.2/glib/gmain.c:3813
    #6 0x7f7ac20c5b57 in g_main_context_iterate /home/mcatanzaro/Projects/WebKit/WebKitBuild/DependenciesGTK/Source/glib-2.54.2/glib/gmain.c:3886
    #7 0x7f7ac20c5e61 in g_main_loop_run /home/mcatanzaro/Projects/WebKit/WebKitBuild/DependenciesGTK/Source/glib-2.54.2/glib/gmain.c:4082
    #8 0x7f7acd13b91b in WTF::RunLoop::run() (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18+0x4c8a91b)
    #9 0x7f7ada78f646 in int WebKit::ChildProcessMain&lt;WebKit::NetworkProcess, WebKit::NetworkProcessMain&gt;(int, char**) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0xa5e6646)
    #10 0x7f7ada78f2f1 in NetworkProcessMainUnix (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0xa5e62f1)
    #11 0x400ec1 in main (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/bin/WebKitNetworkProcess+0x400ec1)
    #12 0x7f7abdbbd009 in __libc_start_main (/lib64/libc.so.6+0x21009)
    #13 0x400d99 in _start (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/bin/WebKitNetworkProcess+0x400d99)

0x611000005d68 is located 168 bytes inside of 224-byte region [0x611000005cc0,0x611000005da0)
freed by thread T0 here:
    #0 0x7f7ae82664b8 in __interceptor_free (/lib64/libasan.so.4+0xde4b8)
    #1 0x7f7acd1511bd in bmalloc::DebugHeap::free(void*) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18+0x4ca01bd)
    #2 0x7f7acd15074e in bmalloc::Deallocator::deallocateSlowCase(void*) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18+0x4c9f74e)
    #3 0x7f7acd04215c in bmalloc::Deallocator::deallocate(void*) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18+0x4b9115c)
    #4 0x7f7acd042574 in bmalloc::Cache::deallocate(bmalloc::HeapKind, void*) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18+0x4b91574)
    #5 0x7f7acd04272a in bmalloc::api::free(void*, bmalloc::HeapKind) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18+0x4b9172a)
    #6 0x7f7acd041444 in WTF::fastFree(void*) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18+0x4b90444)
    #7 0x7f7ad9b3152c in WTF::RefCounted&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt;::operator delete(void*) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0x998852c)
    #8 0x7f7ad9b29554 in WTF::RefCounted&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt;::deref() const (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0x9980554)
    #9 0x7f7ad9b390ef in void WTF::derefIfNotNull&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt;(WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad*) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0x99900ef)
    #10 0x7f7ad9b327a9 in WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt;::~RefPtr() (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0x99897a9)
    #11 0x7f7ad9b47067 in WTF::KeyValuePairHashTraits&lt;WTF::HashTraits&lt;std::pair&lt;unsigned long, unsigned long&gt; &gt;, WTF::HashTraits&lt;WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt; &gt; &gt;::customDeleteBucket(WTF::KeyValuePair&lt;std::pair&lt;unsigned long, unsigned long&gt;, WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt; &gt;&amp;) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0x999e067)
    #12 0x7f7ad9b45bea in std::enable_if&lt;WTF::HashTraitHasCustomDelete&lt;WTF::HashMap&lt;std::pair&lt;unsigned long, unsigned long&gt;, WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt;, WTF::PairHash&lt;unsigned long, unsigned long&gt;, WTF::HashTraits&lt;std::pair&lt;unsigned long, unsigned long&gt; &gt;, WTF::HashTraits&lt;WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt; &gt; &gt;::KeyValuePairTraits, WTF::KeyValuePair&lt;std::pair&lt;unsigned long, unsigned long&gt;, WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt; &gt; &gt;::value, void&gt;::type WTF::hashTraitsDeleteBucket&lt;WTF::HashMap&lt;std::pair&lt;unsigned long, unsigned long&gt;, WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt;, WTF::PairHash&lt;unsigned long, unsigned long&gt;, WTF::HashTraits&lt;std::pair&lt;unsigned long, unsigned long&gt; &gt;, WTF::HashTraits&lt;WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt; &gt; &gt;::KeyValuePairTraits, WTF::KeyValuePair&lt;std::pair&lt;unsigned long, unsigned long&gt;, WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt; &gt; &gt;(WTF::KeyValuePair&lt;std::pair&lt;unsigned long, unsigned long&gt;, WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt; &gt;&amp;) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0x999cbea)
    #13 0x7f7ad9b42e22 in WTF::HashTable&lt;std::pair&lt;unsigned long, unsigned long&gt;, WTF::KeyValuePair&lt;std::pair&lt;unsigned long, unsigned long&gt;, WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt; &gt;, WTF::KeyValuePairKeyExtractor&lt;WTF::KeyValuePair&lt;std::pair&lt;unsigned long, unsigned long&gt;, WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt; &gt; &gt;, WTF::PairHash&lt;unsigned long, unsigned long&gt;, WTF::HashMap&lt;std::pair&lt;unsigned long, unsigned long&gt;, WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt;, WTF::PairHash&lt;unsigned long, unsigned long&gt;, WTF::HashTraits&lt;std::pair&lt;unsigned long, unsigned long&gt; &gt;, WTF::HashTraits&lt;WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt; &gt; &gt;::KeyValuePairTraits, WTF::HashTraits&lt;std::pair&lt;unsigned long, unsigned long&gt; &gt; &gt;::deleteBucket(WTF::KeyValuePair&lt;std::pair&lt;unsigned long, unsigned long&gt;, WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt; &gt;&amp;) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0x9999e22)
    #14 0x7f7ad9b3eae9 in WTF::HashTable&lt;std::pair&lt;unsigned long, unsigned long&gt;, WTF::KeyValuePair&lt;std::pair&lt;unsigned long, unsigned long&gt;, WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt; &gt;, WTF::KeyValuePairKeyExtractor&lt;WTF::KeyValuePair&lt;std::pair&lt;unsigned long, unsigned long&gt;, WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt; &gt; &gt;, WTF::PairHash&lt;unsigned long, unsigned long&gt;, WTF::HashMap&lt;std::pair&lt;unsigned long, unsigned long&gt;, WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt;, WTF::PairHash&lt;unsigned long, unsigned long&gt;, WTF::HashTraits&lt;std::pair&lt;unsigned long, unsigned long&gt; &gt;, WTF::HashTraits&lt;WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt; &gt; &gt;::KeyValuePairTraits, WTF::HashTraits&lt;std::pair&lt;unsigned long, unsigned long&gt; &gt; &gt;::remove(WTF::KeyValuePair&lt;std::pair&lt;unsigned long, unsigned long&gt;, WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt; &gt;*) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0x9995ae9)
    #15 0x7f7ad9b3a760 in WTF::HashTable&lt;std::pair&lt;unsigned long, unsigned long&gt;, WTF::KeyValuePair&lt;std::pair&lt;unsigned long, unsigned long&gt;, WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt; &gt;, WTF::KeyValuePairKeyExtractor&lt;WTF::KeyValuePair&lt;std::pair&lt;unsigned long, unsigned long&gt;, WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt; &gt; &gt;, WTF::PairHash&lt;unsigned long, unsigned long&gt;, WTF::HashMap&lt;std::pair&lt;unsigned long, unsigned long&gt;, WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt;, WTF::PairHash&lt;unsigned long, unsigned long&gt;, WTF::HashTraits&lt;std::pair&lt;unsigned long, unsigned long&gt; &gt;, WTF::HashTraits&lt;WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt; &gt; &gt;::KeyValuePairTraits, WTF::HashTraits&lt;std::pair&lt;unsigned long, unsigned long&gt; &gt; &gt;::removeAndInvalidateWithoutEntryConsistencyCheck(WTF::KeyValuePair&lt;std::pair&lt;unsigned long, unsigned long&gt;, WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt; &gt;*) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0x9991760)
    #16 0x7f7ad9b33f41 in WTF::HashTable&lt;std::pair&lt;unsigned long, unsigned long&gt;, WTF::KeyValuePair&lt;std::pair&lt;unsigned long, unsigned long&gt;, WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt; &gt;, WTF::KeyValuePairKeyExtractor&lt;WTF::KeyValuePair&lt;std::pair&lt;unsigned long, unsigned long&gt;, WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt; &gt; &gt;, WTF::PairHash&lt;unsigned long, unsigned long&gt;, WTF::HashMap&lt;std::pair&lt;unsigned long, unsigned long&gt;, WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt;, WTF::PairHash&lt;unsigned long, unsigned long&gt;, WTF::HashTraits&lt;std::pair&lt;unsigned long, unsigned long&gt; &gt;, WTF::HashTraits&lt;WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt; &gt; &gt;::KeyValuePairTraits, WTF::HashTraits&lt;std::pair&lt;unsigned long, unsigned long&gt; &gt; &gt;::removeWithoutEntryConsistencyCheck(WTF::HashTableIterator&lt;std::pair&lt;unsigned long, unsigned long&gt;, WTF::KeyValuePair&lt;std::pair&lt;unsigned long, unsigned long&gt;, WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt; &gt;, WTF::KeyValuePairKeyExtractor&lt;WTF::KeyValuePair&lt;std::pair&lt;unsigned long, unsigned long&gt;, WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt; &gt; &gt;, WTF::PairHash&lt;unsigned long, unsigned long&gt;, WTF::HashMap&lt;std::pair&lt;unsigned long, unsigned long&gt;, WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt;, WTF::PairHash&lt;unsigned long, unsigned long&gt;, WTF::HashTraits&lt;std::pair&lt;unsigned long, unsigned long&gt; &gt;, WTF::HashTraits&lt;WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt; &gt; &gt;::KeyValuePairTraits, WTF::HashTraits&lt;std::pair&lt;unsigned long, unsigned long&gt; &gt; &gt;) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0x998af41)
    #17 0x7f7ad9b2d4c4 in WTF::HashMap&lt;std::pair&lt;unsigned long, unsigned long&gt;, WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt;, WTF::PairHash&lt;unsigned long, unsigned long&gt;, WTF::HashTraits&lt;std::pair&lt;unsigned long, unsigned long&gt; &gt;, WTF::HashTraits&lt;WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt; &gt; &gt;::remove(WTF::HashTableIteratorAdapter&lt;WTF::HashTable&lt;std::pair&lt;unsigned long, unsigned long&gt;, WTF::KeyValuePair&lt;std::pair&lt;unsigned long, unsigned long&gt;, WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt; &gt;, WTF::KeyValuePairKeyExtractor&lt;WTF::KeyValuePair&lt;std::pair&lt;unsigned long, unsigned long&gt;, WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt; &gt; &gt;, WTF::PairHash&lt;unsigned long, unsigned long&gt;, WTF::HashMap&lt;std::pair&lt;unsigned long, unsigned long&gt;, WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt;, WTF::PairHash&lt;unsigned long, unsigned long&gt;, WTF::HashTraits&lt;std::pair&lt;unsigned long, unsigned long&gt; &gt;, WTF::HashTraits&lt;WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt; &gt; &gt;::KeyValuePairTraits, WTF::HashTraits&lt;std::pair&lt;unsigned long, unsigned long&gt; &gt; &gt;, WTF::KeyValuePair&lt;std::pair&lt;unsigned long, unsigned long&gt;, WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt; &gt; &gt;) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0x99844c4)
    #18 0x7f7ad9b262ea in WTF::HashMap&lt;std::pair&lt;unsigned long, unsigned long&gt;, WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt;, WTF::PairHash&lt;unsigned long, unsigned long&gt;, WTF::HashTraits&lt;std::pair&lt;unsigned long, unsigned long&gt; &gt;, WTF::HashTraits&lt;WTF::RefPtr&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad, WTF::DumbPtrTraits&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt; &gt; &gt; &gt;::remove(std::pair&lt;unsigned long, unsigned long&gt; const&amp;) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0x997d2ea)
    #19 0x7f7ad9b15217 in WebKit::NetworkCache::SpeculativeLoadManager::registerLoad(std::pair&lt;unsigned long, unsigned long&gt; const&amp;, WebCore::ResourceRequest const&amp;, WebKit::NetworkCache::Key const&amp;)::{lambda()#1}::operator()() const (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0x996c217)
    #20 0x7f7ad9b20557 in WTF::Function&lt;void ()&gt;::CallableWrapper&lt;WebKit::NetworkCache::SpeculativeLoadManager::registerLoad(std::pair&lt;unsigned long, unsigned long&gt; const&amp;, WebCore::ResourceRequest const&amp;, WebKit::NetworkCache::Key const&amp;)::{lambda()#1}&gt;::call() (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0x9977557)
    #21 0x7f7ad999bc69 in WTF::Function&lt;void ()&gt;::operator()() const (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0x97f2c69)
    #22 0x7f7ad9b21c11 in WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad::markLoadAsCompleted() (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0x9978c11)
    #23 0x7f7ad9b21dd4 in WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad::PendingFrameLoad(WebKit::NetworkCache::Storage&amp;, WebKit::NetworkCache::Key const&amp;, WTF::Function&lt;void ()&gt;&amp;&amp;)::{lambda(PAL::HysteresisState)#1}::operator()(PAL::HysteresisState) const (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0x9978dd4)
    #24 0x7f7ad9b4a481 in WTF::Function&lt;void (PAL::HysteresisState)&gt;::CallableWrapper&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad::PendingFrameLoad(WebKit::NetworkCache::Storage&amp;, WebKit::NetworkCache::Key const&amp;, WTF::Function&lt;void ()&gt;&amp;&amp;)::{lambda(PAL::HysteresisState)#1}&gt;::call(PAL::HysteresisState) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0x99a1481)
    #25 0x7f7ad9b23f22 in WTF::Function&lt;void (PAL::HysteresisState)&gt;::operator()(PAL::HysteresisState) const (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0x997af22)
    #26 0x7f7ad9b21509 in PAL::HysteresisActivity::hysteresisTimerFired() (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0x9978509)
    #27 0x7f7ad9b4a5c4 in WTF::RunLoop::Timer&lt;PAL::HysteresisActivity&gt;::fired() (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0x99a15c4)
    #28 0x7f7acd13c0ac in WTF::RunLoop::TimerBase::TimerBase(WTF::RunLoop&amp;)::{lambda(void*)#1}::operator()(void*) const (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18+0x4c8b0ac)
    #29 0x7f7acd13c137 in WTF::RunLoop::TimerBase::TimerBase(WTF::RunLoop&amp;)::{lambda(void*)#1}::_FUN(void*) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18+0x4c8b137)

previously allocated by thread T0 here:
    #0 0x7f7ae8266850 in malloc (/lib64/libasan.so.4+0xde850)
    #1 0x7f7acd150f3f in bmalloc::DebugHeap::malloc(unsigned long) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18+0x4c9ff3f)
    #2 0x7f7acd14c6c0 in bmalloc::Allocator::allocateSlowCase(unsigned long) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18+0x4c9b6c0)
    #3 0x7f7acd041fd3 in bmalloc::Allocator::allocate(unsigned long) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18+0x4b90fd3)
    #4 0x7f7acd04230a in bmalloc::Cache::allocate(bmalloc::HeapKind, unsigned long) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18+0x4b9130a)
    #5 0x7f7acd04268a in bmalloc::api::malloc(unsigned long, bmalloc::HeapKind) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18+0x4b9168a)
    #6 0x7f7acd041017 in WTF::fastMalloc(unsigned long) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18+0x4b90017)
    #7 0x7f7ad9b24786 in WTF::RefCounted&lt;WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad&gt;::operator new(unsigned long) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0x997b786)
    #8 0x7f7ad9b217cf in WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad::create(WebKit::NetworkCache::Storage&amp;, WebKit::NetworkCache::Key const&amp;, WTF::Function&lt;void ()&gt;&amp;&amp;) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0x99787cf)
    #9 0x7f7ad9b15921 in WebKit::NetworkCache::SpeculativeLoadManager::registerLoad(std::pair&lt;unsigned long, unsigned long&gt; const&amp;, WebCore::ResourceRequest const&amp;, WebKit::NetworkCache::Key const&amp;) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0x996c921)
    #10 0x7f7ad9aee110 in WebKit::NetworkCache::Cache::retrieve(WebCore::ResourceRequest const&amp;, std::pair&lt;unsigned long, unsigned long&gt; const&amp;, WTF::Function&lt;void (std::unique_ptr&lt;WebKit::NetworkCache::Entry, std::default_delete&lt;WebKit::NetworkCache::Entry&gt; &gt;)&gt;&amp;&amp;) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0x9945110)
    #11 0x7f7ad9a2cbc1 in WebKit::NetworkResourceLoader::retrieveCacheEntry(WebCore::ResourceRequest const&amp;) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0x9883bc1)
    #12 0x7f7ad9a2c93c in WebKit::NetworkResourceLoader::start() (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0x988393c)
    #13 0x7f7ad9995270 in WebKit::NetworkConnectionToWebProcess::scheduleResourceLoad(WebKit::NetworkResourceLoadParameters const&amp;) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0x97ec270)
    #14 0x7f7adad57e77 in void IPC::callMemberFunctionImpl&lt;WebKit::NetworkConnectionToWebProcess, void (WebKit::NetworkConnectionToWebProcess::*)(WebKit::NetworkResourceLoadParameters const&amp;), std::tuple&lt;WebKit::NetworkResourceLoadParameters&gt;, 0ul&gt;(WebKit::NetworkConnectionToWebProcess*, void (WebKit::NetworkConnectionToWebProcess::*)(WebKit::NetworkResourceLoadParameters const&amp;), std::tuple&lt;WebKit::NetworkResourceLoadParameters&gt;&amp;&amp;, std::integer_sequence&lt;unsigned long, 0ul&gt;) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0xabaee77)
    #15 0x7f7adad5505c in void IPC::callMemberFunction&lt;WebKit::NetworkConnectionToWebProcess, void (WebKit::NetworkConnectionToWebProcess::*)(WebKit::NetworkResourceLoadParameters const&amp;), std::tuple&lt;WebKit::NetworkResourceLoadParameters&gt;, std::integer_sequence&lt;unsigned long, 0ul&gt; &gt;(std::tuple&lt;WebKit::NetworkResourceLoadParameters&gt;&amp;&amp;, WebKit::NetworkConnectionToWebProcess*, void (WebKit::NetworkConnectionToWebProcess::*)(WebKit::NetworkResourceLoadParameters const&amp;)) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0xabac05c)
    #16 0x7f7adad4f046 in void IPC::handleMessage&lt;Messages::NetworkConnectionToWebProcess::ScheduleResourceLoad, WebKit::NetworkConnectionToWebProcess, void (WebKit::NetworkConnectionToWebProcess::*)(WebKit::NetworkResourceLoadParameters const&amp;)&gt;(IPC::Decoder&amp;, WebKit::NetworkConnectionToWebProcess*, void (WebKit::NetworkConnectionToWebProcess::*)(WebKit::NetworkResourceLoadParameters const&amp;)) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0xaba6046)
    #17 0x7f7adad4c595 in WebKit::NetworkConnectionToWebProcess::didReceiveNetworkConnectionToWebProcessMessage(IPC::Connection&amp;, IPC::Decoder&amp;) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0xaba3595)
    #18 0x7f7ad9993a86 in WebKit::NetworkConnectionToWebProcess::didReceiveMessage(IPC::Connection&amp;, IPC::Decoder&amp;) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0x97eaa86)
    #19 0x7f7ad9bc66ac in IPC::Connection::dispatchMessage(IPC::Decoder&amp;) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0x9a1d6ac)
    #20 0x7f7ad9bc699b in IPC::Connection::dispatchMessage(std::unique_ptr&lt;IPC::Decoder, std::default_delete&lt;IPC::Decoder&gt; &gt;) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0x9a1d99b)
    #21 0x7f7ad9bc6ed0 in IPC::Connection::dispatchOneMessage() (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0x9a1ded0)
    #22 0x7f7ad9bc6333 in IPC::Connection::enqueueIncomingMessage(std::unique_ptr&lt;IPC::Decoder, std::default_delete&lt;IPC::Decoder&gt; &gt;)::{lambda()#1}::operator()() (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0x9a1d333)
    #23 0x7f7ad9bcf59f in WTF::Function&lt;void ()&gt;::CallableWrapper&lt;IPC::Connection::enqueueIncomingMessage(std::unique_ptr&lt;IPC::Decoder, std::default_delete&lt;IPC::Decoder&gt; &gt;)::{lambda()#1}&gt;::call() (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0x9a2659f)
    #24 0x7f7ad999bc69 in WTF::Function&lt;void ()&gt;::operator()() const (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37+0x97f2c69)
    #25 0x7f7acd08cf2f in WTF::RunLoop::performWork() (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18+0x4bdbf2f)
    #26 0x7f7acd13b0bf in WTF::RunLoop::RunLoop()::{lambda(void*)#1}::operator()(void*) const (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18+0x4c8a0bf)
    #27 0x7f7acd13b0e3 in WTF::RunLoop::RunLoop()::{lambda(void*)#1}::_FUN(void*) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18+0x4c8a0e3)
    #28 0x7f7acd13b05f in WTF::{lambda(_GSource*, int (*)(void*), void*)#1}::operator()(_GSource*, int (*)(void*), void*) const (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18+0x4c8a05f)
    #29 0x7f7acd13b08e in WTF::{lambda(_GSource*, int (*)(void*), void*)#1}::_FUN(_GSource*, int (*)(void*), void*) (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18+0x4c8a08e)

SUMMARY: AddressSanitizer: heap-use-after-free (/home/mcatanzaro/Projects/WebKit/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18+0x4c8b0fb) in WTF::RunLoop::TimerBase::TimerBase(WTF::RunLoop&amp;)::{lambda(void*)#1}::operator()(void*) const
Shadow bytes around the buggy address:
  0x0c227fff8b50: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c227fff8b60: fd fd fd fd fd fd fd fd fa fa fa fa fa fa fa fa
  0x0c227fff8b70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c227fff8b80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c227fff8b90: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd
=&gt;0x0c227fff8ba0: fd fd fd fd fd fd fd fd fd fd fd fd fd[fd]fd fd
  0x0c227fff8bb0: fd fd fd fd fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c227fff8bc0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c227fff8bd0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c227fff8be0: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd
  0x0c227fff8bf0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==21247==ABORTING</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1394503</commentid>
    <comment_count>1</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2018-01-30 04:40:34 -0800</bug_when>
    <thetext>I think the problem is that the pending frame load is deleted inside the hysteresis callback. 

- markLoadAsCompleted() is called by hysteresis
- markLoadAsCompleted() ends up calling m_loadCompletionHandler()
- the completion handler removes the pending frame load from the map which deletes it.

The completion handler is the last thing done by markLoadAsCompleted(), so I&apos;m not sure that&apos;s a problem. Could you try protecting this before calling m_loadCompletionHandler just in case?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1394800</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2018-01-30 15:30:12 -0800</bug_when>
    <thetext>(In reply to Carlos Garcia Campos from comment #1)
&gt; I think the problem is that the pending frame load is deleted inside the
&gt; hysteresis callback. 
&gt; 
&gt; - markLoadAsCompleted() is called by hysteresis
&gt; - markLoadAsCompleted() ends up calling m_loadCompletionHandler()
&gt; - the completion handler removes the pending frame load from the map which
&gt; deletes it.
&gt; 
&gt; The completion handler is the last thing done by markLoadAsCompleted(), so
&gt; I&apos;m not sure that&apos;s a problem. Could you try protecting this before calling
&gt; m_loadCompletionHandler just in case?

Seems like a nice explanation; now I think I finally understand it. I spent too much time squinting at the RunLoop code, and not enough looking at SpeculativeLoadManager. The problem probably doesn&apos;t occur for Cocoa ports because their Timer does not do extra work immediately after firing its callback, but ours needs to reset the ready time.

Adding a protector does not help, probably because even with the protector, the Timer is still dead when control returns to its source callback.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1394802</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2018-01-30 15:38:28 -0800</bug_when>
    <thetext>I think our RunLoop::Timer might be the only one that is not robust to being destroyed during its user callback, and I don&apos;t see an easy fix for SpeculativeLoadManager, but it is simple to fix in our RunLoop::Timer, so I suggest we leave SpeculativeLoadManager alone and change our RunLoop::Timer instead. CCing Chris just in case he wants to change SpeculativeLoadManager anyway.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1394808</commentid>
    <comment_count>4</comment_count>
      <attachid>332717</attachid>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2018-01-30 15:52:38 -0800</bug_when>
    <thetext>Created attachment 332717
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1394809</commentid>
    <comment_count>5</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2018-01-30 15:54:10 -0800</bug_when>
    <thetext>(In reply to Michael Catanzaro from comment #3)
&gt; CCing Chris just in case he wants to change SpeculativeLoadManager anyway.

(Probably not, because it&apos;s tricky to fix, but the current code is relying on platform-specific implementation details of RunLoop, which is a bit dangerous.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1394929</commentid>
    <comment_count>6</comment_count>
      <attachid>332717</attachid>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2018-01-31 00:13:49 -0800</bug_when>
    <thetext>Comment on attachment 332717
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=332717&amp;action=review

Have you checked that asan doesn&apos;t report any issues in speculative loader after this patch?

&gt; Source/WTF/wtf/glib/RunLoopGLib.cpp:171
&gt; +        if (g_source_is_destroyed(g_main_current_source()))
&gt; +            return G_SOURCE_REMOVE;

Why don&apos;t we keep a pointer to the source before calling fired instead of using g_main_current_source()? I also wonder if we could simply update the ready time before calling fired() instead. RunLoopGeneric has the same problem, btw:

    bool fired()
    {
        if (!isActive())
            return false;

        m_function();

        if (!m_isRepeating)
            return false;

        updateReadyTime();
     	return isActive();
    }</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1394998</commentid>
    <comment_count>7</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2018-01-31 08:25:00 -0800</bug_when>
    <thetext>(In reply to Carlos Garcia Campos from comment #6)
&gt; Why don&apos;t we keep a pointer to the source before calling fired instead of
&gt; using g_main_current_source()?

Sure, I considered doing that. It&apos;s an extra ref/unref operation, no big deal.

&gt; I also wonder if we could simply update the
&gt; ready time before calling fired() instead.

I don&apos;t know. Changing this would be somewhat scarier. But I think it should be fine....

&gt; RunLoopGeneric has the same
&gt; problem, btw:
&gt; 
&gt;     bool fired()
&gt;     {
&gt;         if (!isActive())
&gt;             return false;
&gt; 
&gt;         m_function();
&gt; 
&gt;         if (!m_isRepeating)
&gt;             return false;
&gt; 
&gt;         updateReadyTime();
&gt;      	return isActive();
&gt;     }

Indeed. I did check to see if it was a problem there, but clearly I messed up, as usual.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1395163</commentid>
    <comment_count>8</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2018-01-31 14:45:41 -0800</bug_when>
    <thetext>Yusuke, it doesn&apos;t look simple to fix RunLoopGeneric, because it will be deleted before the return from m_function(). Do you have any opinion on how we should handle this?

If we aren&apos;t able to change RunLoopGeneric, then we should try to come up with some way to assert that the Timer has not deleted itself, which is also going to be quite tricky to implement.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1395239</commentid>
    <comment_count>9</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2018-01-31 16:45:13 -0800</bug_when>
    <thetext>I&apos;m investigating our options for RunLoopGeneric.

(In reply to Michael Catanzaro from comment #7)
&gt; I don&apos;t know. Changing this would be somewhat scarier. But I think it should
&gt; be fine....

I think it would be OK, but I&apos;m really not sure, so I am going to stick with keeping a local ref of the GSource.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1395250</commentid>
    <comment_count>10</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2018-01-31 16:55:23 -0800</bug_when>
    <thetext>Sorry for the spam Ryosuke, I saw you modified Timer and thought you might be interested... but it was a different Timer.

(In reply to Michael Catanzaro from comment #9)
&gt; I&apos;m investigating our options for RunLoopGeneric.

ScheduledTask is ThreadSafeRefCounted. That was a good design decision. I bet all it needs is a protector. I&apos;m going to file a separate bug for this so we can land it separately, because I haven&apos;t tested it. Bug #182365.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1395299</commentid>
    <comment_count>11</comment_count>
      <attachid>332834</attachid>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2018-01-31 18:48:33 -0800</bug_when>
    <thetext>Created attachment 332834
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1395372</commentid>
    <comment_count>12</comment_count>
      <attachid>332834</attachid>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2018-01-31 23:55:36 -0800</bug_when>
    <thetext>Comment on attachment 332834
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=332834&amp;action=review

&gt; Source/WTF/wtf/glib/RunLoopGLib.cpp:169
&gt; +        GRefPtr&lt;GSource&gt; protectedSource = timer-&gt;m_source;

We don&apos;t need a ref, the source is reffed by dispatch before calling this callback un unreffed after, so it will be alive for sure after calling fired().</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1395584</commentid>
    <comment_count>13</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2018-02-01 11:41:17 -0800</bug_when>
    <thetext>Committed r227976: &lt;https://trac.webkit.org/changeset/227976&gt;</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>332717</attachid>
            <date>2018-01-30 15:52:38 -0800</date>
            <delta_ts>2018-01-31 18:48:31 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>bug-182271-20180130175237.patch</filename>
            <type>text/plain</type>
            <size>2247</size>
            <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pLCBSdW5M
b29wU291cmNlUHJpb3JpdHk6OlJ1bkxvb3BUaW1lcik7CiAgICAgZ19zb3VyY2Vfc2V0X25hbWUo
bV9zb3VyY2UuZ2V0KCksICJbV2ViS2l0XSBSdW5Mb29wOjpUaW1lciB3b3JrIik7CiAgICAgZ19z
b3VyY2Vfc2V0X2NhbGxiYWNrKG1fc291cmNlLmdldCgpLCBbXShncG9pbnRlciB1c2VyRGF0YSkg
LT4gZ2Jvb2xlYW4geworICAgICAgICAvLyBmaXJlZCgpIGV4ZWN1dGVzIHRoZSB1c2VyJ3MgY2Fs
bGJhY2suIEl0IG1heSBkZXN0cm95IHRpbWVyLCB3aGljaCBpcworICAgICAgICAvLyB3aHkgd2Ug
bXVzdCBjaGVjayBpZiB0aGUgc291cmNlIGlzIHN0aWxsIGFjdGl2ZSBhZnRlcndhcmRzIGJlZm9y
ZSBpdAorICAgICAgICAvLyBpcyBzYWZlIHRvIGRlcmVmZXJlbmNlIHRpbWVyIGFnYWluLgogICAg
ICAgICBSdW5Mb29wOjpUaW1lckJhc2UqIHRpbWVyID0gc3RhdGljX2Nhc3Q8UnVuTG9vcDo6VGlt
ZXJCYXNlKj4odXNlckRhdGEpOwogICAgICAgICB0aW1lci0+ZmlyZWQoKTsKKyAgICAgICAgaWYg
KGdfc291cmNlX2lzX2Rlc3Ryb3llZChnX21haW5fY3VycmVudF9zb3VyY2UoKSkpCisgICAgICAg
ICAgICByZXR1cm4gR19TT1VSQ0VfUkVNT1ZFOwogICAgICAgICBpZiAodGltZXItPm1faXNSZXBl
YXRpbmcpCiAgICAgICAgICAgICB0aW1lci0+dXBkYXRlUmVhZHlUaW1lKCk7CiAgICAgICAgIHJl
dHVybiBHX1NPVVJDRV9DT05USU5VRTsK
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>332834</attachid>
            <date>2018-01-31 18:48:33 -0800</date>
            <delta_ts>2018-01-31 23:55:36 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>bug-182271-20180131204832.patch</filename>
            <type>text/plain</type>
            <size>2301</size>
            <attacher name="Michael Catanzaro">mcatanzaro</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjI3OTQzCmRpZmYgLS1naXQgYS9Tb3VyY2UvV1RGL0NoYW5n
ZUxvZyBiL1NvdXJjZS9XVEYvQ2hhbmdlTG9nCmluZGV4IDJiNDU0NjU1ODA5NDE5ODQ1M2ZkYzc3
YmE4M2EzOGEwOWE1M2RkOTYuLjU0YzFmNWRiOGE0MDRjOTI1NzY3ZGE1ZWViODhhM2Y4MWU4YzRl
Y2EgMTAwNjQ0Ci0tLSBhL1NvdXJjZS9XVEYvQ2hhbmdlTG9nCisrKyBiL1NvdXJjZS9XVEYvQ2hh
bmdlTG9nCkBAIC0xLDMgKzEsMTkgQEAKKzIwMTgtMDEtMzEgIE1pY2hhZWwgQ2F0YW56YXJvICA8
bWNhdGFuemFyb0BpZ2FsaWEuY29tPgorCisgICAgICAgIFtXUEVdW0dUS10gTWFrZSBSdW5Mb29w
OjpUaW1lckJhc2Ugcm9idXN0IHRvIGl0cyBvd24gZGVsZXRpb24gaW5zaWRlIGl0cyBzb3VyY2Ug
Y2FsbGJhY2sKKyAgICAgICAgaHR0cHM6Ly9idWdzLndlYmtpdC5vcmcvc2hvd19idWcuY2dpP2lk
PTE4MjI3MQorCisgICAgICAgIFJldmlld2VkIGJ5IE5PQk9EWSAoT09QUyEpLgorCisgICAgICAg
IFJ1bkxvb3BUaW1lcjo6ZmlyZWQgZXhlY3V0ZXMgdGhlIHVzZXIncyBjYWxsYmFjaywgd2hpY2gg
Y291bGQgZGVsZXRlIHRoZSBSdW5Mb29wVGltZXIKKyAgICAgICAgaXRzZWxmLiBCdXQgdGhlIHNv
dXJjZSBjYWxsYmFjayBpcyBub3QgcHJlcGFyZWQgdG8gaGFuZGxlIHRoaXMgY2FzZS4gV2UgY2Fu
IGRldGVjdCBpdAorICAgICAgICBlYXNp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          id="351749"
          type_id="1"
          status="+"
          setter="cgarcia"
    />
          </attachment>
      

    </bug>

</bugzilla>