Ignore:
Timestamp:
Sep 4, 2019, 7:52:46 PM (6 years ago)
Author:
[email protected]
Message:

[JSC] FunctionOverrides should have a lock to ensure concurrent access to hash table does not happen
https://bugs.webkit.org/show_bug.cgi?id=201485

Reviewed by Tadeu Zagallo.

FunctionOverrides is a per-process singleton for registering overrides information. But we are accessing
it without taking a lock. If multiple threads with multiple VMs are accessing this concurrently, we have
a race issue like,

  1. While one thread is adding overrides information,
  2. Another thread is accessing this hash table.

This patch adds a lock to make sure that only one thread can access this registry.

  • tools/FunctionOverrides.cpp:

(JSC::FunctionOverrides::FunctionOverrides):
(JSC::FunctionOverrides::reinstallOverrides):
(JSC::FunctionOverrides::initializeOverrideFor):
(JSC::FunctionOverrides::parseOverridesInFile):

  • tools/FunctionOverrides.h:

(JSC::FunctionOverrides::clear):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/tools/FunctionOverrides.h

    r243365 r249518  
    2828#include "SourceCode.h"
    2929#include <wtf/HashMap.h>
     30#include <wtf/Lock.h>
    3031#include <wtf/text/WTFString.h>
    3132
     
    5758
    5859private:
    59     void parseOverridesInFile(const char* fileName);
    60     void clear() { m_entries.clear(); }
     60    void parseOverridesInFile(const AbstractLocker&, const char* fileName);
     61    void clear(const AbstractLocker&) { m_entries.clear(); }
    6162
    6263    HashMap<String, String> m_entries;
     64    Lock m_lock;
    6365};
    6466
Note: See TracChangeset for help on using the changeset viewer.