google / googletest

GoogleTest - Google Testing and Mocking Framework
https://google.github.io/googletest/
BSD 3-Clause "New" or "Revised" License
33.67k stars 9.98k forks source link

crash when using TEST_F and try-catch in VS2015 in Release x64 #1869

Closed lk12 closed 5 years ago

lk12 commented 5 years ago

I get a crash in gtest-1.8.0 in Windows10 VS2015.3 when using TEST_F with try-catch when compiling for Release x64. See code below

`class TestAccessViolation : public ::testing::Test { protected: std::vector numbers; };

// replacing TEST_F with TEST and moving TestRecorderAccessViolation::numbers to the beginning of // AccessViolationDueExceptionOnWin64Release makes the problem work TEST_F(TestAccessViolation, DISABLED_AccessViolationDueExceptionOnWin64Release) { std::cout << "This test crashes for unknown reasons on release Windows x64. Perhaps caused by bug in gtest in combination with eager optimization. Re-test with Visual Studio vs2017 and gtest-1.8.1+?" << std::endl; // using EXPECT_THROW here will make the test proceed try { throw std::runtime_error("TEST"); } catch (const std::exception&) { } auto const ID = 1001; numbers.push_back(ID); // note how changing the following line affects the error message EXPECT_TRUE(true); EXPECT_EQ(ID, numbers.front()); // using the debugger it seems that all pointers ov mEventIds should be valid EXPECT_EQ(ID, numbers.back()); }`

Compiler

Microsoft Visual Studio Professional 2015 Version 14.0.25431.01 Update 3 Microsoft .NET Framework Version 4.7.03062

Installed Version: Professional

Visual Basic 2015 00322-50050-35329-AA542 Microsoft Visual Basic 2015

Visual C# 2015 00322-50050-35329-AA542 Microsoft Visual C# 2015

Visual C++ 2015 00322-50050-35329-AA542 Microsoft Visual C++ 2015

Application Insights Tools for Visual Studio Package 1.0 Application Insights Tools for Visual Studio

CEVSAddonPackage 1.0 Information about my package

ClangFormat 1.0 Formats code by calling the clang-format executable.

Common Azure Tools 1.8 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

GitHub.VisualStudio 2.5.5.3913 A Visual Studio Extension that brings the GitHub Flow into Visual Studio.

Google Test Adapter 1.0 Google Test Adapter adds support for the C++ test framework Google Test

JavaScript Language Service 2.0 JavaScript Language Service

JavaScript Project System 2.0 JavaScript Project System

Microsoft Azure Mobile Services Tools 1.4 Microsoft Azure Mobile Services Tools

NuGet Package Manager 3.4.4 NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

PreEmptive Analytics Visualizer 1.2 Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

Python Tools for Visual Studio 2.2.50113.00 Python Tools for Visual Studio provides IntelliSense, projects, templates, Interactive windows, and other support for Python developers.

Python Tools for Visual Studio - Django Integration 2.2.50113.00 Provides templates and integration for the Django web framework.

Python Tools for Visual Studio - Profiling Support 2.2.50113.00 Profiling support for Python projects.

StopOnFirstBuildError 1.0 StopOnFirstBuildError

Stops a solution build immediately after a project has failed to build.

http://tech.einaregilsson.com/2011/01/06/stop-build-on-first-error-in-visual-studio-2010/

TypeScript 1.8.36.0 TypeScript tools for Visual Studio

gennadiycivil commented 5 years ago

Thank you very much for this report. The best way to approach this would be to create a proper PR and submit it for consideration.

gennadiycivil commented 5 years ago

I have been cleaning up older and inactive GitHub googletest issues. You may see an issue "closed" if it appears to be inactive/abandoned Thank you