Changeset 207071 in webkit
- Timestamp:
- Oct 11, 2016 2:23:28 AM (8 years ago)
- Location:
- releases/WebKitGTK/webkit-2.14/Source/WTF
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
releases/WebKitGTK/webkit-2.14/Source/WTF/ChangeLog
r207070 r207071 1 2016-09-12 Filip Pizlo <fpizlo@apple.com> 2 3 ParkingLot is going to have a bad time with threads dying 4 https://bugs.webkit.org/show_bug.cgi?id=161893 5 6 Reviewed by Michael Saboff. 7 8 If a thread dies right as it falls out of parkConditionally, then unparkOne() and friends 9 might die because they will dereference a deallocated ThreadData. 10 11 The solution is to ref-count ThreadData's. When unparkOne() and friends want to hold onto a 12 ThreadData past the queue lock, they can use RefPtr<>. 13 14 * wtf/ParkingLot.cpp: 15 (WTF::ParkingLot::unparkOne): 16 (WTF::ParkingLot::unparkOneImpl): 17 (WTF::ParkingLot::unparkAll): 18 1 19 2016-09-12 Yusuke Suzuki <utatane.tea@gmail.com> 2 20 -
releases/WebKitGTK/webkit-2.14/Source/WTF/wtf/ParkingLot.cpp
r205717 r207071 46 46 const bool verbose = false; 47 47 48 struct ThreadData {48 struct ThreadData : public ThreadSafeRefCounted<ThreadData> { 49 49 WTF_MAKE_FAST_ALLOCATED; 50 50 public: … … 246 246 }; 247 247 248 ThreadSpecific<ThreadData>* threadData;249 248 Atomic<Hashtable*> hashtable; 250 249 Atomic<unsigned> numThreads; … … 449 448 ThreadData* myThreadData() 450 449 { 450 static ThreadSpecific<RefPtr<ThreadData>>* threadData; 451 451 static std::once_flag initializeOnce; 452 452 std::call_once( 453 453 initializeOnce, 454 454 [] { 455 threadData = new ThreadSpecific< ThreadData>();455 threadData = new ThreadSpecific<RefPtr<ThreadData>>(); 456 456 }); 457 458 return *threadData; 457 458 RefPtr<ThreadData>& result = **threadData; 459 460 if (!result) 461 result = adoptRef(new ThreadData()); 462 463 return result.get(); 459 464 } 460 465 … … 660 665 UnparkResult result; 661 666 662 ThreadData* threadData = nullptr;667 RefPtr<ThreadData> threadData; 663 668 result.mayHaveMoreThreads = dequeue( 664 669 address, … … 698 703 dataLog(toString(currentThread(), ": unparking one the hard way.\n")); 699 704 700 ThreadData* threadData = nullptr;705 RefPtr<ThreadData> threadData; 701 706 bool timeToBeFair = false; 702 707 dequeue( … … 739 744 dataLog(toString(currentThread(), ": unparking all from ", RawPointer(address), ".\n")); 740 745 741 Vector< ThreadData*, 8> threadDatas;746 Vector<RefPtr<ThreadData>, 8> threadDatas; 742 747 dequeue( 743 748 address, … … 753 758 [] (bool) { }); 754 759 755 for ( ThreadData*threadData : threadDatas) {760 for (RefPtr<ThreadData>& threadData : threadDatas) { 756 761 if (verbose) 757 dataLog(toString(currentThread(), ": unparking ", RawPointer(threadData ), " with address ", RawPointer(threadData->address), "\n"));762 dataLog(toString(currentThread(), ": unparking ", RawPointer(threadData.get()), " with address ", RawPointer(threadData->address), "\n")); 758 763 ASSERT(threadData->address); 759 764 {
Note: See TracChangeset
for help on using the changeset viewer.