Changeset 245871 in webkit


Ignore:
Timestamp:
May 29, 2019 3:07:24 PM (5 years ago)
Author:
ddkilzer@apple.com
Message:

IndexedDatabase Server thread in com.apple.WebKit.Networking process leaks objects into an autoreleasePool that's never cleared
<https://webkit.org/b/198346>
<rdar://problem/50895658>

Reviewed by Brent Fulgham.

Source/WebCore:

  • Modules/indexeddb/server/IDBServer.cpp:

(WebCore::IDBServer::IDBServer::IDBServer):

  • Pass AutodrainedPoolForRunLoop::Use when creating CrossThreadTaskHandler to fix the bug.

Source/WTF:

  • wtf/CrossThreadTaskHandler.cpp:

(WTF::CrossThreadTaskHandler::CrossThreadTaskHandler):

  • Add optional second argument to enable use of an AutodrainedPool when running the runloop.

(WTF::CrossThreadTaskHandler::taskRunLoop):

  • Create an AutodrainedPool if requested when CrossThreadTaskHandler was created.
  • wtf/CrossThreadTaskHandler.h:

(WTF::CrossThreadTaskHandler::AutodrainedPoolForRunLoop):

  • Add enum class for enabling an AutodrainedPool for CrossThreadTaskHandler::taskRunLoop().

(WTF::CrossThreadTaskHandler::CrossThreadTaskHandler):

  • Add optional second argument to enable use of an AutodrainedPool when running the runloop.
Location:
trunk/Source
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r245868 r245871  
     12019-05-29  David Kilzer  <ddkilzer@apple.com>
     2
     3        IndexedDatabase Server thread in com.apple.WebKit.Networking process leaks objects into an autoreleasePool that's never cleared
     4        <https://webkit.org/b/198346>
     5        <rdar://problem/50895658>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        * wtf/CrossThreadTaskHandler.cpp:
     10        (WTF::CrossThreadTaskHandler::CrossThreadTaskHandler):
     11        - Add optional second argument to enable use of an
     12          AutodrainedPool when running the runloop.
     13        (WTF::CrossThreadTaskHandler::taskRunLoop):
     14        - Create an AutodrainedPool if requested when
     15          CrossThreadTaskHandler was created.
     16        * wtf/CrossThreadTaskHandler.h:
     17        (WTF::CrossThreadTaskHandler::AutodrainedPoolForRunLoop):
     18        - Add enum class for enabling an AutodrainedPool for
     19          CrossThreadTaskHandler::taskRunLoop().
     20        (WTF::CrossThreadTaskHandler::CrossThreadTaskHandler):
     21        - Add optional second argument to enable use of an
     22          AutodrainedPool when running the runloop.
     23
    1242019-05-29  Geoffrey Garen  <ggaren@apple.com>
    225
  • trunk/Source/WTF/wtf/CrossThreadTaskHandler.cpp

    r244687 r245871  
    2727#include <wtf/CrossThreadTaskHandler.h>
    2828
     29#include <wtf/AutodrainedPool.h>
     30
    2931namespace WTF {
    3032
    31 CrossThreadTaskHandler::CrossThreadTaskHandler(const char* threadName)
     33CrossThreadTaskHandler::CrossThreadTaskHandler(const char* threadName, AutodrainedPoolForRunLoop useAutodrainedPool)
     34    : m_useAutodrainedPool(useAutodrainedPool)
    3235{
    3336    ASSERT(isMainThread());
     
    7073
    7174    while (!m_taskQueue.isKilled()) {
    72         m_taskQueue.waitForMessage().performTask();
     75        {
     76            std::unique_ptr<AutodrainedPool> autodrainedPool = (m_useAutodrainedPool == AutodrainedPoolForRunLoop::Use) ? std::make_unique<AutodrainedPool>() : nullptr;
     77
     78            m_taskQueue.waitForMessage().performTask();
     79        }
    7380
    7481        Locker<Lock> shouldSuspendLocker(m_shouldSuspendLock);
  • trunk/Source/WTF/wtf/CrossThreadTaskHandler.h

    r244687 r245871  
    3939public:
    4040    WTF_EXPORT_PRIVATE virtual ~CrossThreadTaskHandler();
     41    enum class AutodrainedPoolForRunLoop { DoNotUse, Use };
    4142
    4243protected:
    43     WTF_EXPORT_PRIVATE CrossThreadTaskHandler(const char* threadName);
     44    WTF_EXPORT_PRIVATE CrossThreadTaskHandler(const char* threadName, AutodrainedPoolForRunLoop = AutodrainedPoolForRunLoop::DoNotUse);
    4445
    4546    WTF_EXPORT_PRIVATE void postTask(CrossThreadTask&&);
     
    5152    void handleTaskRepliesOnMainThread();
    5253    void taskRunLoop();
     54
     55    AutodrainedPoolForRunLoop m_useAutodrainedPool { AutodrainedPoolForRunLoop::DoNotUse };
    5356
    5457    Lock m_taskThreadCreationLock;
  • trunk/Source/WebCore/ChangeLog

    r245868 r245871  
     12019-05-29  David Kilzer  <ddkilzer@apple.com>
     2
     3        IndexedDatabase Server thread in com.apple.WebKit.Networking process leaks objects into an autoreleasePool that's never cleared
     4        <https://webkit.org/b/198346>
     5        <rdar://problem/50895658>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        * Modules/indexeddb/server/IDBServer.cpp:
     10        (WebCore::IDBServer::IDBServer::IDBServer):
     11        - Pass AutodrainedPoolForRunLoop::Use when creating
     12          CrossThreadTaskHandler to fix the bug.
     13
    1142019-05-29  Geoffrey Garen  <ggaren@apple.com>
    215
  • trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp

    r244687 r245871  
    5858
    5959IDBServer::IDBServer(PAL::SessionID sessionID, IDBBackingStoreTemporaryFileHandler& fileHandler, QuotaManagerGetter&& quotaManagerGetter)
    60     : CrossThreadTaskHandler("IndexedDatabase Server")
     60    : CrossThreadTaskHandler("IndexedDatabase Server", AutodrainedPoolForRunLoop::Use)
    6161    , m_sessionID(sessionID)
    6262    , m_backingStoreTemporaryFileHandler(fileHandler)
     
    6666
    6767IDBServer::IDBServer(PAL::SessionID sessionID, const String& databaseDirectoryPath, IDBBackingStoreTemporaryFileHandler& fileHandler, QuotaManagerGetter&& quotaManagerGetter)
    68     : CrossThreadTaskHandler("IndexedDatabase Server")
     68    : CrossThreadTaskHandler("IndexedDatabase Server", AutodrainedPoolForRunLoop::Use)
    6969    , m_sessionID(sessionID)
    7070    , m_databaseDirectoryPath(databaseDirectoryPath)
Note: See TracChangeset for help on using the changeset viewer.