Changeset 186006 in webkit


Ignore:
Timestamp:
Jun 26, 2015 12:21:02 PM (9 years ago)
Author:
Antti Koivisto
Message:

Network process hangs fetching disk cache entries
https://bugs.webkit.org/show_bug.cgi?id=146348
<rdar://problem/21528072>

Reviewed by Anders Carlsson.

RunLoop::dispatch may deadlock if invoked with std::function that captures an object that calls RunLoop::dispatch in destructor.

  • wtf/RunLoop.cpp:

(WTF::RunLoop::performWork):

Don't reuse std::function variable in loop. We may end up destroying previously held std::function in assignment
while holding the runloop mutex. With this change std::function is always destroyed with mutex unlocked.

Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r185907 r186006  
     12015-06-26  Antti Koivisto  <antti@apple.com>
     2
     3        Network process hangs fetching disk cache entries
     4        https://bugs.webkit.org/show_bug.cgi?id=146348
     5        <rdar://problem/21528072>
     6
     7        Reviewed by Anders Carlsson.
     8
     9        RunLoop::dispatch may deadlock if invoked with std::function that captures an object that calls RunLoop::dispatch in destructor.
     10
     11        * wtf/RunLoop.cpp:
     12        (WTF::RunLoop::performWork):
     13
     14            Don't reuse std::function variable in loop. We may end up destroying previously held std::function in assignment
     15            while holding the runloop mutex. With this change std::function is always destroyed with mutex unlocked.
     16
    1172015-06-24  Commit Queue  <commit-queue@webkit.org>
    218
  • trunk/Source/WTF/wtf/RunLoop.cpp

    r180434 r186006  
    8989    // we guarantee to occasionally return from the run loop so other event sources will be allowed to spin.
    9090
    91     std::function<void()> function;
    9291    size_t functionsToHandle = 0;
     92    {
     93        std::function<void()> function;
     94        {
     95            MutexLocker locker(m_functionQueueLock);
     96            functionsToHandle = m_functionQueue.size();
    9397
    94     {
    95         MutexLocker locker(m_functionQueueLock);
    96         functionsToHandle = m_functionQueue.size();
     98            if (m_functionQueue.isEmpty())
     99                return;
    97100
    98         if (m_functionQueue.isEmpty())
    99             return;
     101            function = m_functionQueue.takeFirst();
     102        }
    100103
    101         function = m_functionQueue.takeFirst();
     104        function();
    102105    }
    103106
    104     function();
    105 
    106107    for (size_t functionsHandled = 1; functionsHandled < functionsToHandle; ++functionsHandled) {
     108        std::function<void()> function;
    107109        {
    108110            MutexLocker locker(m_functionQueueLock);
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r185915 r186006  
    300300                E19DB9791B32137C00DB38D4 /* NavigatorLanguage.mm in Sources */ = {isa = PBXBuildFile; fileRef = E19DB9781B32137C00DB38D4 /* NavigatorLanguage.mm */; };
    301301                E40019331ACE9B88001B0A2A /* BloomFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E40019301ACE9B5C001B0A2A /* BloomFilter.cpp */; };
     302                E4C9ABC91B3DB2C40040A987 /* RunLoop.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4C9ABC71B3DB1710040A987 /* RunLoop.cpp */; };
    302303                F660AA1115A5F631003A1243 /* GetInjectedBundleInitializationUserDataCallback_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F660AA0F15A5F624003A1243 /* GetInjectedBundleInitializationUserDataCallback_Bundle.cpp */; };
    303304                F660AA1515A61ABF003A1243 /* InjectedBundleInitializationUserDataCallbackWins_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F660AA1415A61ABF003A1243 /* InjectedBundleInitializationUserDataCallbackWins_Bundle.cpp */; };
     
    728729                E490296714E2E3A4002BEDD1 /* TypingStyleCrash.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TypingStyleCrash.mm; sourceTree = "<group>"; };
    729730                E4A757D3178AEA5B00B5D7A4 /* Deque.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Deque.cpp; sourceTree = "<group>"; };
     731                E4C9ABC71B3DB1710040A987 /* RunLoop.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RunLoop.cpp; sourceTree = "<group>"; };
    730732                F3FC3EE213678B7300126A65 /* libgtest.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libgtest.a; sourceTree = BUILT_PRODUCTS_DIR; };
    731733                F660AA0C15A5F061003A1243 /* GetInjectedBundleInitializationUserDataCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GetInjectedBundleInitializationUserDataCallback.cpp; sourceTree = "<group>"; };
     
    10971099                                93A427AD180DA60F00CD24D7 /* RefLogger.h */,
    10981100                                93A427A8180D9B0700CD24D7 /* RefPtr.cpp */,
     1101                                E4C9ABC71B3DB1710040A987 /* RunLoop.cpp */,
    10991102                                14F3B11215E45EAB00210069 /* SaturatedArithmeticOperations.cpp */,
    11001103                                CD5393C91757BAC400C07123 /* SHA1.cpp */,
     
    15281531                                7CCE7F071A411AE600447C4C /* PageLoadBasic.cpp in Sources */,
    15291532                                7CCE7F081A411AE600447C4C /* PageLoadDidChangeLocationWithinPageForFrame.cpp in Sources */,
     1533                                E4C9ABC91B3DB2C40040A987 /* RunLoop.cpp in Sources */,
    15301534                                7CCE7EC71A411A7E00447C4C /* PageVisibilityStateWithWindowChanges.mm in Sources */,
    15311535                                7CCE7F091A411AE600447C4C /* ParentFrame.cpp in Sources */,
Note: See TracChangeset for help on using the changeset viewer.