diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gtest-death-test.cc | 9 | ||||
-rw-r--r-- | src/gtest-internal-inl.h | 2 | ||||
-rw-r--r-- | src/gtest_main.cc | 2 |
3 files changed, 10 insertions, 3 deletions
diff --git a/src/gtest-death-test.cc b/src/gtest-death-test.cc index 3b73b01d..66bf1898 100644 --- a/src/gtest-death-test.cc +++ b/src/gtest-death-test.cc @@ -418,7 +418,14 @@ void DeathTestImpl::Abort(AbortReason reason) { const char status_ch = reason == TEST_DID_NOT_DIE ? kDeathTestLived : kDeathTestReturned; GTEST_DEATH_TEST_CHECK_SYSCALL_(posix::Write(write_fd(), &status_ch, 1)); - GTEST_DEATH_TEST_CHECK_SYSCALL_(posix::Close(write_fd())); + // We are leaking the descriptor here because on some platforms (i.e., + // when built as Windows DLL), destructors of global objects will still + // run after calling _exit(). On such systems, write_fd_ will be + // indirectly closed from the destructor of UnitTestImpl, causing double + // close if it is also closed here. On debug configurations, double close + // may assert. As there are no in-process buffers to flush here, we are + // relying on the OS to close the descriptor after the process terminates + // when the destructors are not run. _exit(1); // Exits w/o any normal exit hooks (we were supposed to crash) } diff --git a/src/gtest-internal-inl.h b/src/gtest-internal-inl.h index 855b2155..a3cda754 100644 --- a/src/gtest-internal-inl.h +++ b/src/gtest-internal-inl.h @@ -977,7 +977,7 @@ GTEST_API_ void ParseGoogleTestFlagsOnly(int* argc, wchar_t** argv); // Returns the message describing the last system error, regardless of the // platform. -String GetLastErrnoDescription(); +GTEST_API_ String GetLastErrnoDescription(); #if GTEST_OS_WINDOWS // Provides leak-safe Windows kernel handle ownership. diff --git a/src/gtest_main.cc b/src/gtest_main.cc index d20c02fd..6d4d22d2 100644 --- a/src/gtest_main.cc +++ b/src/gtest_main.cc @@ -31,7 +31,7 @@ #include <gtest/gtest.h> -int main(int argc, char **argv) { +GTEST_API_ int main(int argc, char **argv) { std::cout << "Running main() from gtest_main.cc\n"; testing::InitGoogleTest(&argc, argv); |