ソースを参照

Fixed hang in FixedSizeFreeList::DestructObjectBatch when object has non-trivial destructor (#1269)

Fixes #1267
Jorrit Rouwe 11 ヶ月 前
コミット
ca53350133
1 ファイル変更5 行追加1 行削除
  1. 5 1
      Jolt/Core/FixedSizeFreeList.inl

+ 5 - 1
Jolt/Core/FixedSizeFreeList.inl

@@ -108,9 +108,13 @@ uint32 FixedSizeFreeList<Object>::ConstructObject(Parameters &&... inParameters)
 template <typename Object>
 void FixedSizeFreeList<Object>::AddObjectToBatch(Batch &ioBatch, uint32 inObjectIndex)
 {
-	JPH_ASSERT(GetStorage(inObjectIndex).mNextFreeObject.load(memory_order_relaxed) == inObjectIndex, "Trying to add a object to the batch that is already in a free list");
 	JPH_ASSERT(ioBatch.mNumObjects != uint32(-1), "Trying to reuse a batch that has already been freed");
 
+	// Reset next index
+	atomic<uint32> &next_free_object = GetStorage(inObjectIndex).mNextFreeObject;
+	JPH_ASSERT(next_free_object.load(memory_order_relaxed) == inObjectIndex, "Trying to add a object to the batch that is already in a free list");
+	next_free_object.store(cInvalidObjectIndex, memory_order_release);
+
 	// Link object in batch to free
 	if (ioBatch.mFirstObjectIndex == cInvalidObjectIndex)
 		ioBatch.mFirstObjectIndex = inObjectIndex;