diff --git a/modules/dnn/test/test_layers.cpp b/modules/dnn/test/test_layers.cpp index e4d844a3e1..18a4f19fc5 100644 --- a/modules/dnn/test/test_layers.cpp +++ b/modules/dnn/test/test_layers.cpp @@ -90,13 +90,12 @@ public: TEST(Layer_NonZeroDeathTest, partition_independence) { #if GTEST_HAS_DEATH_TEST - // Re-execution needs GTest's saved working directory; otherwise use fork on POSIX. + // Re-execution needs GTest's saved working directory. Fork-only execution is + // unsafe when the test process already has threads (for example, on macOS). const bool canReexec = ::testing::UnitTest::GetInstance()->original_working_dir()[0] != '\0'; -#if defined(_WIN32) if (!canReexec) throw SkipTestException("NonZero partition test requires GTest subprocess support"); -#endif - ::testing::GTEST_FLAG(death_test_style) = canReexec ? "threadsafe" : "fast"; + ::testing::GTEST_FLAG(death_test_style) = "threadsafe"; // Keep the process-global backend override in the child, including on assertion failure. EXPECT_EXIT(([] { Mat input(4, 8, CV_32F, Scalar(1));