Death tests use fork(), which is unsafe particularly in a threaded context. For this test, Google Test detected 3 threads.
Demo:
void Foo()
{
int *pInt = 0;
*pInt = 42 ;
}
TEST(FooDeathTest, Demo)
{
testing::FLAGS_gtest_death_test_style = "threadsafe";
EXPECT_DEATH(Foo(), "");
}
解决方法:
增加:
testing::FLAGS_gtest_death_test_style = "threadsafe";