Changeset 189517 in webkit
- Timestamp:
- Sep 8, 2015 5:19:15 PM (9 years ago)
- Location:
- trunk/Source
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r189516 r189517 1 2015-09-08 Mark Lam <mark.lam@apple.com> 2 3 GC stack scan should include ABI red zone. 4 https://bugs.webkit.org/show_bug.cgi?id=148976 5 6 Reviewed by Geoffrey Garen and Benjamin Poulain. 7 8 The x86_64 ABI section 3.2.2[1] and ARM64 ABI[2] both state that there is a 9 128 byte red zone below the stack pointer (reserved by the OS), and that 10 "functions may use this area for temporary data that is not needed across 11 function calls". 12 13 Hence, it is possible for a thread to store JSCell pointers in the red zone 14 area, and the conservative GC thread scanner needs to scan that area as well. 15 16 Note: the red zone should not be scanned for the GC thread itself (in 17 gatherFromCurrentThread()). This because we're guaranteed that there will 18 be GC frames below the lowest (top of stack) frame that we need to scan. 19 Hence, we are guaranteed that there are no red zone areas there containing 20 JSObject pointers of relevance. 21 22 No test added for this issue because the issue relies on: 23 1. the compiler tool chain generating code that stores local variables 24 containing the sole reference to a JS object (that needs to be kept 25 alive) in the stack red zone, and 26 2. GC has to run on another thread while that red zone containing the 27 JS object reference is in use. 28 29 These conditions require a race that cannot be reliably reproduced. 30 31 [1]: http://people.freebsd.org/~obrien/amd64-elf-abi.pdf 32 [2]: https://developer.apple.com/library/ios/documentation/Xcode/Conceptual/iPhoneOSABIReference/Articles/ARM64FunctionCallingConventions.html#//apple_ref/doc/uid/TP40013702-SW7 33 34 * heap/MachineStackMarker.cpp: 35 (JSC::MachineThreads::Thread::Thread): 36 (JSC::MachineThreads::Thread::createForCurrentThread): 37 (JSC::MachineThreads::Thread::freeRegisters): 38 (JSC::osRedZoneAdjustment): 39 (JSC::MachineThreads::Thread::captureStack): 40 1 41 2015-09-08 Geoffrey Garen <ggaren@apple.com> 2 42 -
trunk/Source/JavaScriptCore/heap/MachineStackMarker.cpp
r188499 r189517 161 161 WTF_MAKE_FAST_ALLOCATED; 162 162 163 Thread(const PlatformThread& platThread, void* base )163 Thread(const PlatformThread& platThread, void* base, void* end) 164 164 : platformThread(platThread) 165 165 , stackBase(base) 166 , stackEnd(end) 166 167 { 167 168 #if USE(PTHREADS) && !OS(WINDOWS) && !OS(DARWIN) && defined(SA_RESTART) … … 196 197 static Thread* createForCurrentThread() 197 198 { 198 return new Thread(getCurrentPlatformThread(), wtfThreadData().stack().origin()); 199 auto stackBounds = wtfThreadData().stack(); 200 return new Thread(getCurrentPlatformThread(), stackBounds.origin(), stackBounds.end()); 199 201 } 200 202 … … 242 244 PlatformThread platformThread; 243 245 void* stackBase; 246 void* stackEnd; 244 247 #if OS(WINDOWS) 245 248 HANDLE platformThreadHandle; … … 511 514 } 512 515 516 static inline int osRedZoneAdjustment() 517 { 518 int redZoneAdjustment = 0; 519 #if !OS(WINDOWS) 520 #if CPU(X86_64) 521 // See http://people.freebsd.org/~obrien/amd64-elf-abi.pdf Section 3.2.2. 522 redZoneAdjustment = -128; 523 #elif CPU(ARM64) 524 // See https://developer.apple.com/library/ios/documentation/Xcode/Conceptual/iPhoneOSABIReference/Articles/ARM64FunctionCallingConventions.html#//apple_ref/doc/uid/TP40013702-SW7 525 redZoneAdjustment = -128; 526 #endif 527 #endif // OS(DARWIN) 528 return redZoneAdjustment; 529 } 530 513 531 std::pair<void*, size_t> MachineThreads::Thread::captureStack(void* stackTop) 514 532 { 515 void* begin = stackBase; 516 void* end = reinterpret_cast<void*>( 517 WTF::roundUpToMultipleOf<sizeof(void*)>(reinterpret_cast<uintptr_t>(stackTop))); 518 if (begin > end) 519 std::swap(begin, end); 520 return std::make_pair(begin, static_cast<char*>(end) - static_cast<char*>(begin)); 533 char* begin = reinterpret_cast_ptr<char*>(stackBase); 534 char* end = reinterpret_cast_ptr<char*>(WTF::roundUpToMultipleOf<sizeof(void*)>(reinterpret_cast<uintptr_t>(stackTop))); 535 ASSERT(begin >= end); 536 537 char* endWithRedZone = end + osRedZoneAdjustment(); 538 ASSERT(WTF::roundUpToMultipleOf<sizeof(void*)>(reinterpret_cast<uintptr_t>(endWithRedZone)) == reinterpret_cast<uintptr_t>(endWithRedZone)); 539 540 if (endWithRedZone < stackEnd) 541 endWithRedZone = reinterpret_cast_ptr<char*>(stackEnd); 542 543 std::swap(begin, endWithRedZone); 544 return std::make_pair(begin, endWithRedZone - begin); 521 545 } 522 546 -
trunk/Source/WTF/ChangeLog
r189367 r189517 1 2015-09-08 Mark Lam <mark.lam@apple.com> 2 3 GC stack scan should include ABI red zone. 4 https://bugs.webkit.org/show_bug.cgi?id=148976 5 6 Reviewed by Geoffrey Garen and Benjamin Poulain. 7 8 * wtf/StackBounds.h: 9 (WTF::StackBounds::origin): 10 (WTF::StackBounds::end): 11 (WTF::StackBounds::size): 12 1 13 2015-09-04 Csaba Osztrogonác <ossy@webkit.org> 2 14 -
trunk/Source/WTF/wtf/StackBounds.h
r173949 r189517 55 55 } 56 56 57 void* end() const 58 { 59 ASSERT(m_bound); 60 return m_bound; 61 } 62 57 63 size_t size() const 58 64 {
Note: See TracChangeset
for help on using the changeset viewer.