Просмотр исходного кода

test: try to reproduce a crash with reentrant destructors and asan enabled

skypjack 4 дней назад
Родитель
Сommit
5731e9400b
1 измененных файлов с 20 добавлено и 0 удалено
  1. 20 0
      test/entt/entity/storage.cpp

+ 20 - 0
test/entt/entity/storage.cpp

@@ -1772,6 +1772,26 @@ TEST(Storage, UpdateFromDestructor) {
     }
 }
 
+TEST(Storage, UpdateFromDestructorOnDestroy) {
+    using entity_type = StorageBase::my_entity;
+
+    constexpr auto size = 10u;
+    const std::array entity{entity_type{4u}, entity_type{2u}, entity_type{0u}};
+
+    for(auto target: entity) {
+        entt::basic_storage<StorageBase::update_from_destructor, entity_type> pool;
+
+        for(std::size_t next{}; next < size; ++next) {
+            const auto other = entity_type(next);
+            pool.emplace(other, pool, other == entity_type(size / 2) ? target : other);
+        }
+
+        pool.erase(entity_type(size / 2));
+
+        // the storage goes out of scope here
+    }
+}
+
 TEST(Storage, CreateFromConstructor) {
     using entity_type = StorageBase::my_entity;