Skip to content

[Impeller] race condition in ResourceManagerVK in golden tests #142083

@gaaclarke

Description

@gaaclarke

The following crash happens when validation is turned on for all golden image tests. I ran the test runner with GuardMalloc and the crash didn't happen, which points to a race condition.

blocking #142017

reproduction steps

Apply the following patch so all tests (modulo #142080) are run:

--- a/impeller/golden_tests/golden_playground_test_mac.cc
+++ b/impeller/golden_tests/golden_playground_test_mac.cc
@@ -77,9 +77,8 @@ static const std::vector<std::string> kSkipTests = {
 
 /// TODO(https://github.com/flutter/flutter/issues/142017): Turn on validation
 /// for all vulkan tests.
-static const std::vector<std::string> kVulkanValidationTests = {
-    "impeller_Play_AiksTest_CanRenderImageRect_Vulkan",
-    "impeller_Play_AiksTest_CanRenderTextFrame_Vulkan",
+static const std::vector<std::string> kVulkanNonValidationTests = {
+    "impeller_Play_AiksTest_EmptySaveLayerRendersWithClear_Vulkan",
 };
 
 namespace {
@@ -113,11 +112,12 @@ bool SaveScreenshot(std::unique_ptr<testing::Screenshot> screenshot) {
 }
 
 bool ShouldTestHaveVulkanValidations() {
-  bool enable_vulkan_validations = false;
+  bool enable_vulkan_validations = true;
   std::string test_name = GetTestName();
-  if (std::find(kVulkanValidationTests.begin(), kVulkanValidationTests.end(),
-                test_name) != kVulkanValidationTests.end()) {
-    enable_vulkan_validations = true;
+  if (std::find(kVulkanNonValidationTests.begin(),
+                kVulkanNonValidationTests.end(),
+                test_name) != kVulkanNonValidationTests.end()) {
+    enable_vulkan_validations = false;
   }
   return enable_vulkan_validations;
 }

Then execute impeller_golden_tests --working_dir=~/temp/ --gtest_filter="*Vulkan"

callstack

libsystem_kernel.dylib!__pthread_kill (Unknown Source:0)
libsystem_pthread.dylib!pthread_kill (Unknown Source:0)
libsystem_c.dylib!abort (Unknown Source:0)
libc++abi.dylib!abort_message (Unknown Source:0)
libc++abi.dylib!demangling_terminate_handler() (Unknown Source:0)
libobjc.A.dylib!_objc_terminate() (Unknown Source:0)
libc++abi.dylib!std::__terminate(void (*)()) (Unknown Source:0)
libc++abi.dylib!__cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) (Unknown Source:0)
libc++abi.dylib!__cxa_throw (Unknown Source:0)
libc++.1.dylib!std::__1::__throw_system_error(int, char const*) (Unknown Source:0)
libc++.1.dylib!std::__1::mutex::lock() (Unknown Source:0)
libc++.1.dylib!std::__1::__shared_mutex_base::lock() (Unknown Source:0)
libVkLayer_khronos_validation.dylib!StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice_T*, VkCommandPool_T*, unsigned int, VkCommandBuffer_T* const*) (Unknown Source:0)
libVkLayer_khronos_validation.dylib!vulkan_layer_chassis::FreeCommandBuffers(VkDevice_T*, VkCommandPool_T*, unsigned int, VkCommandBuffer_T* const*) (Unknown Source:0)
impeller_golden_tests!void impeller::vk::Device::free<impeller::vk::DispatchLoaderDynamic>(impeller::vk::CommandPool, impeller::vk::ArrayProxy<impeller::vk::CommandBuffer const> const&, impeller::vk::DispatchLoaderDynamic const&) const (/Users/aaclarke/dev/engine/src/third_party/vulkan-deps/vulkan-headers/src/include/vulkan/vulkan_funcs.hpp:4217)
impeller_golden_tests!void impeller::vk::PoolFree<impeller::vk::Device, impeller::vk::CommandPool, impeller::vk::DispatchLoaderDynamic>::destroy<impeller::vk::CommandBuffer>(impeller::vk::CommandBuffer) (/Users/aaclarke/dev/engine/src/third_party/vulkan-deps/vulkan-headers/src/include/vulkan/vulkan.hpp:6140)
impeller_golden_tests!impeller::vk::UniqueHandle<impeller::vk::CommandBuffer, impeller::vk::DispatchLoaderDynamic>::~UniqueHandle() (/Users/aaclarke/dev/engine/src/third_party/vulkan-deps/vulkan-headers/src/include/vulkan/vulkan.hpp:1202)
impeller_golden_tests!impeller::vk::UniqueHandle<impeller::vk::CommandBuffer, impeller::vk::DispatchLoaderDynamic>::~UniqueHandle() (/Users/aaclarke/dev/engine/src/third_party/vulkan-deps/vulkan-headers/src/include/vulkan/vulkan.hpp:1199)
impeller_golden_tests!std::_fl::allocator<impeller::vk::UniqueHandle<impeller::vk::CommandBuffer, impeller::vk::DispatchLoaderDynamic>>::destroy[abi:v15000](impeller::vk::UniqueHandle<impeller::vk::CommandBuffer, impeller::vk::DispatchLoaderDynamic>*) (/Users/aaclarke/dev/engine/src/third_party/libcxx/include/__memory/allocator.h:170)
impeller_golden_tests!void std::_fl::allocator_traits<std::_fl::allocator<impeller::vk::UniqueHandle<impeller::vk::CommandBuffer, impeller::vk::DispatchLoaderDynamic>>>::destroy[abi:v15000]<impeller::vk::UniqueHandle<impeller::vk::CommandBuffer, impeller::vk::DispatchLoaderDynamic>, void>(std::_fl::allocator<impeller::vk::UniqueHandle<impeller::vk::CommandBuffer, impeller::vk::DispatchLoaderDynamic>>&, impeller::vk::UniqueHandle<impeller::vk::CommandBuffer, impeller::vk::DispatchLoaderDynamic>*) (/Users/aaclarke/dev/engine/src/third_party/libcxx/include/__memory/allocator_traits.h:309)
impeller_golden_tests!std::_fl::vector<impeller::vk::UniqueHandle<impeller::vk::CommandBuffer, impeller::vk::DispatchLoaderDynamic>, std::_fl::allocator<impeller::vk::UniqueHandle<impeller::vk::CommandBuffer, impeller::vk::DispatchLoaderDynamic>>>::__base_destruct_at_end[abi:v15000](impeller::vk::UniqueHandle<impeller::vk::CommandBuffer, impeller::vk::DispatchLoaderDynamic>*) (/Users/aaclarke/dev/engine/src/third_party/libcxx/include/vector:820)
impeller_golden_tests!std::_fl::vector<impeller::vk::UniqueHandle<impeller::vk::CommandBuffer, impeller::vk::DispatchLoaderDynamic>, std::_fl::allocator<impeller::vk::UniqueHandle<impeller::vk::CommandBuffer, impeller::vk::DispatchLoaderDynamic>>>::__clear[abi:v15000]() (/Users/aaclarke/dev/engine/src/third_party/libcxx/include/vector:814)
impeller_golden_tests!std::_fl::vector<impeller::vk::UniqueHandle<impeller::vk::CommandBuffer, impeller::vk::DispatchLoaderDynamic>, std::_fl::allocator<impeller::vk::UniqueHandle<impeller::vk::CommandBuffer, impeller::vk::DispatchLoaderDynamic>>>::clear[abi:v15000]() (/Users/aaclarke/dev/engine/src/third_party/libcxx/include/vector:627)
impeller_golden_tests!impeller::BackgroundCommandPoolVK::~BackgroundCommandPoolVK() (/Users/aaclarke/dev/engine/src/flutter/impeller/renderer/backend/vulkan/command_pool_vk.cc:43)
impeller_golden_tests!impeller::BackgroundCommandPoolVK::~BackgroundCommandPoolVK() (/Users/aaclarke/dev/engine/src/flutter/impeller/renderer/backend/vulkan/command_pool_vk.cc:33)
impeller_golden_tests!impeller::ResourceVKT<impeller::BackgroundCommandPoolVK>::~ResourceVKT() (/Users/aaclarke/dev/engine/src/flutter/impeller/renderer/backend/vulkan/resource_manager_vk.h:114)
impeller_golden_tests!impeller::ResourceVKT<impeller::BackgroundCommandPoolVK>::~ResourceVKT() (/Users/aaclarke/dev/engine/src/flutter/impeller/renderer/backend/vulkan/resource_manager_vk.h:114)
impeller_golden_tests!impeller::ResourceVKT<impeller::BackgroundCommandPoolVK>::~ResourceVKT() (/Users/aaclarke/dev/engine/src/flutter/impeller/renderer/backend/vulkan/resource_manager_vk.h:114)
impeller_golden_tests!std::_fl::default_delete<impeller::ResourceVK>::operator()[abi:v15000](impeller::ResourceVK*) const (/Users/aaclarke/dev/engine/src/third_party/libcxx/include/__memory/unique_ptr.h:48)
impeller_golden_tests!std::_fl::unique_ptr<impeller::ResourceVK, std::_fl::default_delete<impeller::ResourceVK>>::reset[abi:v15000](impeller::ResourceVK*) (/Users/aaclarke/dev/engine/src/third_party/libcxx/include/__memory/unique_ptr.h:305)
impeller_golden_tests!std::_fl::unique_ptr<impeller::ResourceVK, std::_fl::default_delete<impeller::ResourceVK>>::~unique_ptr[abi:v15000]() (/Users/aaclarke/dev/engine/src/third_party/libcxx/include/__memory/unique_ptr.h:259)
impeller_golden_tests!std::_fl::unique_ptr<impeller::ResourceVK, std::_fl::default_delete<impeller::ResourceVK>>::~unique_ptr[abi:v15000]() (/Users/aaclarke/dev/engine/src/third_party/libcxx/include/__memory/unique_ptr.h:259)
impeller_golden_tests!std::_fl::allocator<std::_fl::unique_ptr<impeller::ResourceVK, std::_fl::default_delete<impeller::ResourceVK>>>::destroy[abi:v15000](std::_fl::unique_ptr<impeller::ResourceVK, std::_fl::default_delete<impeller::ResourceVK>>*) (/Users/aaclarke/dev/engine/src/third_party/libcxx/include/__memory/allocator.h:170)
impeller_golden_tests!void std::_fl::allocator_traits<std::_fl::allocator<std::_fl::unique_ptr<impeller::ResourceVK, std::_fl::default_delete<impeller::ResourceVK>>>>::destroy[abi:v15000]<std::_fl::unique_ptr<impeller::ResourceVK, std::_fl::default_delete<impeller::ResourceVK>>, void>(std::_fl::allocator<std::_fl::unique_ptr<impeller::ResourceVK, std::_fl::default_delete<impeller::ResourceVK>>>&, std::_fl::unique_ptr<impeller::ResourceVK, std::_fl::default_delete<impeller::ResourceVK>>*) (/Users/aaclarke/dev/engine/src/third_party/libcxx/include/__memory/allocator_traits.h:309)
impeller_golden_tests!std::_fl::vector<std::_fl::unique_ptr<impeller::ResourceVK, std::_fl::default_delete<impeller::ResourceVK>>, std::_fl::allocator<std::_fl::unique_ptr<impeller::ResourceVK, std::_fl::default_delete<impeller::ResourceVK>>>>::__base_destruct_at_end[abi:v15000](std::_fl::unique_ptr<impeller::ResourceVK, std::_fl::default_delete<impeller::ResourceVK>>*) (/Users/aaclarke/dev/engine/src/third_party/libcxx/include/vector:820)
impeller_golden_tests!std::_fl::vector<std::_fl::unique_ptr<impeller::ResourceVK, std::_fl::default_delete<impeller::ResourceVK>>, std::_fl::allocator<std::_fl::unique_ptr<impeller::ResourceVK, std::_fl::default_delete<impeller::ResourceVK>>>>::__clear[abi:v15000]() (/Users/aaclarke/dev/engine/src/third_party/libcxx/include/vector:814)
impeller_golden_tests!std::_fl::vector<std::_fl::unique_ptr<impeller::ResourceVK, std::_fl::default_delete<impeller::ResourceVK>>, std::_fl::allocator<std::_fl::unique_ptr<impeller::ResourceVK, std::_fl::default_delete<impeller::ResourceVK>>>>::clear[abi:v15000]() (/Users/aaclarke/dev/engine/src/third_party/libcxx/include/vector:627)
impeller_golden_tests!impeller::ResourceManagerVK::Start() (/Users/aaclarke/dev/engine/src/flutter/impeller/renderer/backend/vulkan/resource_manager_vk.cc:69)
impeller_golden_tests!impeller::ResourceManagerVK::ResourceManagerVK()::$_0::operator()() const (/Users/aaclarke/dev/engine/src/flutter/impeller/renderer/backend/vulkan/resource_manager_vk.cc:23)
impeller_golden_tests!decltype(std::declval<impeller::ResourceManagerVK::ResourceManagerVK()::$_0>()()) std::_fl::__invoke[abi:v15000]<impeller::ResourceManagerVK::ResourceManagerVK()::$_0>(impeller::ResourceManagerVK::ResourceManagerVK()::$_0&&) (/Users/aaclarke/dev/engine/src/third_party/libcxx/include/__functional/invoke.h:403)
impeller_golden_tests!_ZNSt3_fl16__thread_executeB6v15000INS_10unique_ptrINS_15__thread_structENS_14default_deleteIS2_EEEEZN8impeller17ResourceManagerVKC1EvE3$_0JETpTnmJEEEvRNS_5tupleIJT_T0_DpT1_EEENS_15__tuple_indicesIJXspT2_EEEE (/Users/aaclarke/dev/engine/src/third_party/libcxx/include/thread:284)
impeller_golden_tests!void* std::_fl::__thread_proxy[abi:v15000]<std::_fl::tuple<std::_fl::unique_ptr<std::_fl::__thread_struct, std::_fl::default_delete<std::_fl::__thread_struct>>, impeller::ResourceManagerVK::ResourceManagerVK()::$_0>>(void*) (/Users/aaclarke/dev/engine/src/third_party/libcxx/include/thread:295)
libsystem_pthread.dylib!_pthread_start (Unknown Source:0)

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work liste: impellerImpeller rendering backend issues and features requeststeam-engineOwned by Engine teamtriaged-engineTriaged by Engine team

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions