Changeset 249518 in webkit
- Timestamp:
- Sep 4, 2019 7:52:46 PM (5 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r249509 r249518 1 2019-09-04 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] FunctionOverrides should have a lock to ensure concurrent access to hash table does not happen 4 https://bugs.webkit.org/show_bug.cgi?id=201485 5 6 Reviewed by Tadeu Zagallo. 7 8 FunctionOverrides is a per-process singleton for registering overrides information. But we are accessing 9 it without taking a lock. If multiple threads with multiple VMs are accessing this concurrently, we have 10 a race issue like, 11 12 1. While one thread is adding overrides information, 13 2. Another thread is accessing this hash table. 14 15 This patch adds a lock to make sure that only one thread can access this registry. 16 17 * tools/FunctionOverrides.cpp: 18 (JSC::FunctionOverrides::FunctionOverrides): 19 (JSC::FunctionOverrides::reinstallOverrides): 20 (JSC::FunctionOverrides::initializeOverrideFor): 21 (JSC::FunctionOverrides::parseOverridesInFile): 22 * tools/FunctionOverrides.h: 23 (JSC::FunctionOverrides::clear): 24 1 25 2019-09-04 Yusuke Suzuki <ysuzuki@apple.com> 2 26 -
trunk/Source/JavaScriptCore/tools/FunctionOverrides.cpp
r248552 r249518 103 103 FunctionOverrides::FunctionOverrides(const char* overridesFileName) 104 104 { 105 parseOverridesInFile( overridesFileName);105 parseOverridesInFile(holdLock(m_lock), overridesFileName); 106 106 } 107 107 … … 109 109 { 110 110 FunctionOverrides& overrides = FunctionOverrides::overrides(); 111 auto locker = holdLock(overrides.m_lock); 111 112 const char* overridesFileName = Options::functionOverrides(); 112 overrides.clear( );113 overrides.parseOverridesInFile( overridesFileName);113 overrides.clear(locker); 114 overrides.parseOverridesInFile(locker, overridesFileName); 114 115 } 115 116 … … 152 153 String sourceBodyString = sourceString.substring(sourceBodyStart); 153 154 154 auto it = overrides.m_entries.find(sourceBodyString); 155 if (it == overrides.m_entries.end()) 156 return false; 157 158 initializeOverrideInfo(origCode, it->value, result); 155 String newBody; 156 { 157 auto locker = holdLock(overrides.m_lock); 158 auto it = overrides.m_entries.find(sourceBodyString.isolatedCopy()); 159 if (it == overrides.m_entries.end()) 160 return false; 161 newBody = it->value.isolatedCopy(); 162 } 163 164 initializeOverrideInfo(origCode, newBody, result); 159 165 return true; 160 166 } … … 228 234 } 229 235 230 void FunctionOverrides::parseOverridesInFile(const char* fileName)236 void FunctionOverrides::parseOverridesInFile(const AbstractLocker&, const char* fileName) 231 237 { 232 238 if (!fileName) -
trunk/Source/JavaScriptCore/tools/FunctionOverrides.h
r243365 r249518 28 28 #include "SourceCode.h" 29 29 #include <wtf/HashMap.h> 30 #include <wtf/Lock.h> 30 31 #include <wtf/text/WTFString.h> 31 32 … … 57 58 58 59 private: 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(); } 61 62 62 63 HashMap<String, String> m_entries; 64 Lock m_lock; 63 65 }; 64 66
Note: See TracChangeset
for help on using the changeset viewer.