parent
ddf218776e
commit
24687ea437
@ -1,98 +0,0 @@
|
||||
From 0663ce9024c9b78ddf6eb3fc1ceb45361ed91767 Mon Sep 17 00:00:00 2001
|
||||
From: Romain Geissler <romain.geissler@gmail.com>
|
||||
Date: Sat, 2 Dec 2017 22:47:20 +0100
|
||||
Subject: [PATCH] Fix double free when building Gtest/GMock in shared libraries
|
||||
and linking a test executable with both.
|
||||
|
||||
---
|
||||
googlemock/CMakeLists.txt | 63 ++++++++++++++++++++++++++++++-----------------
|
||||
1 file changed, 40 insertions(+), 23 deletions(-)
|
||||
|
||||
diff --git a/googlemock/CMakeLists.txt b/googlemock/CMakeLists.txt
|
||||
index 724fdd5..f7bad8a 100644
|
||||
--- a/googlemock/CMakeLists.txt
|
||||
+++ b/googlemock/CMakeLists.txt
|
||||
@@ -86,16 +86,23 @@ endif()
|
||||
# Google Mock libraries. We build them using more strict warnings than what
|
||||
# are used for other targets, to ensure that Google Mock can be compiled by
|
||||
# a user aggressive about warnings.
|
||||
-cxx_library(gmock
|
||||
- "${cxx_strict}"
|
||||
- "${gtest_dir}/src/gtest-all.cc"
|
||||
- src/gmock-all.cc)
|
||||
-
|
||||
-cxx_library(gmock_main
|
||||
- "${cxx_strict}"
|
||||
- "${gtest_dir}/src/gtest-all.cc"
|
||||
- src/gmock-all.cc
|
||||
- src/gmock_main.cc)
|
||||
+if (MSVC)
|
||||
+ cxx_library(gmock
|
||||
+ "${cxx_strict}"
|
||||
+ "${gtest_dir}/src/gtest-all.cc"
|
||||
+ src/gmock-all.cc)
|
||||
+
|
||||
+ cxx_library(gmock_main
|
||||
+ "${cxx_strict}"
|
||||
+ "${gtest_dir}/src/gtest-all.cc"
|
||||
+ src/gmock-all.cc
|
||||
+ src/gmock_main.cc)
|
||||
+else()
|
||||
+ cxx_library(gmock "${cxx_strict}" src/gmock-all.cc)
|
||||
+ target_link_libraries(gmock gtest)
|
||||
+ cxx_library(gmock_main "${cxx_strict}" src/gmock_main.cc)
|
||||
+ target_link_libraries(gmock_main gmock)
|
||||
+endif()
|
||||
|
||||
# If the CMake version supports it, attach header directory information
|
||||
# to the targets for when we are part of a parent build (ie being pulled
|
||||
@@ -175,23 +182,33 @@ if (gmock_build_tests)
|
||||
############################################################
|
||||
# C++ tests built with non-standard compiler flags.
|
||||
|
||||
- cxx_library(gmock_main_no_exception "${cxx_no_exception}"
|
||||
- "${gtest_dir}/src/gtest-all.cc" src/gmock-all.cc src/gmock_main.cc)
|
||||
-
|
||||
- cxx_library(gmock_main_no_rtti "${cxx_no_rtti}"
|
||||
- "${gtest_dir}/src/gtest-all.cc" src/gmock-all.cc src/gmock_main.cc)
|
||||
+ if (MSVC)
|
||||
+ cxx_library(gmock_main_no_exception "${cxx_no_exception}"
|
||||
+ "${gtest_dir}/src/gtest-all.cc" src/gmock-all.cc src/gmock_main.cc)
|
||||
|
||||
- if (NOT MSVC OR MSVC_VERSION LESS 1600) # 1600 is Visual Studio 2010.
|
||||
- # Visual Studio 2010, 2012, and 2013 define symbols in std::tr1 that
|
||||
- # conflict with our own definitions. Therefore using our own tuple does not
|
||||
- # work on those compilers.
|
||||
- cxx_library(gmock_main_use_own_tuple "${cxx_use_own_tuple}"
|
||||
+ cxx_library(gmock_main_no_rtti "${cxx_no_rtti}"
|
||||
"${gtest_dir}/src/gtest-all.cc" src/gmock-all.cc src/gmock_main.cc)
|
||||
|
||||
- cxx_test_with_flags(gmock_use_own_tuple_test "${cxx_use_own_tuple}"
|
||||
- gmock_main_use_own_tuple test/gmock-spec-builders_test.cc)
|
||||
+ if (MSVC_VERSION LESS 1600) # 1600 is Visual Studio 2010.
|
||||
+ # Visual Studio 2010, 2012, and 2013 define symbols in std::tr1 that
|
||||
+ # conflict with our own definitions. Therefore using our own tuple does not
|
||||
+ # work on those compilers.
|
||||
+ cxx_library(gmock_main_use_own_tuple "${cxx_use_own_tuple}"
|
||||
+ "${gtest_dir}/src/gtest-all.cc" src/gmock-all.cc src/gmock_main.cc)
|
||||
+
|
||||
+ cxx_test_with_flags(gmock_use_own_tuple_test "${cxx_use_own_tuple}"
|
||||
+ gmock_main_use_own_tuple test/gmock-spec-builders_test.cc)
|
||||
+ endif()
|
||||
+ else()
|
||||
+ cxx_library(gmock_main_no_exception "${cxx_no_exception}" src/gmock_main.cc)
|
||||
+ target_link_libraries(gmock_main_no_exception gmock)
|
||||
+
|
||||
+ cxx_library(gmock_main_no_rtti "${cxx_no_rtti}" src/gmock_main.cc)
|
||||
+ target_link_libraries(gmock_main_no_rtti gmock)
|
||||
+
|
||||
+ cxx_library(gmock_main_use_own_tuple "${cxx_use_own_tuple}" src/gmock_main.cc)
|
||||
+ target_link_libraries(gmock_main_use_own_tuple gmock)
|
||||
endif()
|
||||
-
|
||||
cxx_test_with_flags(gmock-more-actions_no_exception_test "${cxx_no_exception}"
|
||||
gmock_main_no_exception test/gmock-more-actions_test.cc)
|
||||
|
||||
--
|
||||
2.14.3
|
||||
|
@ -1,24 +0,0 @@
|
||||
diff -up googletest-release-1.8.0/googlemock/CMakeLists.txt.libdir googletest-release-1.8.0/googlemock/CMakeLists.txt
|
||||
--- googletest-release-1.8.0/googlemock/CMakeLists.txt.libdir 2016-08-31 16:20:48.805836249 -0600
|
||||
+++ googletest-release-1.8.0/googlemock/CMakeLists.txt 2016-08-31 16:19:24.596216228 -0600
|
||||
@@ -104,7 +104,7 @@ endif()
|
||||
#
|
||||
# Install rules
|
||||
install(TARGETS gmock gmock_main
|
||||
- DESTINATION lib)
|
||||
+ DESTINATION lib${LIB_SUFFIX})
|
||||
install(DIRECTORY ${gmock_SOURCE_DIR}/include/gmock
|
||||
DESTINATION include)
|
||||
|
||||
diff -up googletest-release-1.8.0/googletest/CMakeLists.txt.libdir googletest-release-1.8.0/googletest/CMakeLists.txt
|
||||
--- googletest-release-1.8.0/googletest/CMakeLists.txt.libdir 2016-07-14 11:15:38.000000000 -0600
|
||||
+++ googletest-release-1.8.0/googletest/CMakeLists.txt 2016-08-31 16:20:19.357969126 -0600
|
||||
@@ -103,7 +103,7 @@ endif()
|
||||
#
|
||||
# Install rules
|
||||
install(TARGETS gtest gtest_main
|
||||
- DESTINATION lib)
|
||||
+ DESTINATION lib${LIB_SUFFIX})
|
||||
install(DIRECTORY ${gtest_SOURCE_DIR}/include/gtest
|
||||
DESTINATION include)
|
||||
|
@ -1,34 +0,0 @@
|
||||
From 62466cfccad1a4fe3f59a2c33104c40adc01b4fe Mon Sep 17 00:00:00 2001
|
||||
From: Jonathan Wakely <jwakely@redhat.com>
|
||||
Date: Fri, 23 Dec 2016 01:56:14 +0000
|
||||
Subject: [PATCH] Stop TestInfo::Run() calling a function through null pointer
|
||||
|
||||
If the object was never created then trying to call &Test::DeleteSelf_
|
||||
will dereference a null pointer, with undefined behaviour.
|
||||
|
||||
Fixes #845
|
||||
---
|
||||
googletest/src/gtest.cc | 10 ++++++----
|
||||
1 file changed, 6 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
|
||||
index d882ab2..1fb05ea 100644
|
||||
--- a/googletest/src/gtest.cc
|
||||
+++ b/googletest/src/gtest.cc
|
||||
@@ -2656,10 +2656,12 @@ void TestInfo::Run() {
|
||||
test->Run();
|
||||
}
|
||||
|
||||
- // Deletes the test object.
|
||||
- impl->os_stack_trace_getter()->UponLeavingGTest();
|
||||
- internal::HandleExceptionsInMethodIfSupported(
|
||||
- test, &Test::DeleteSelf_, "the test fixture's destructor");
|
||||
+ if (test != NULL) {
|
||||
+ // Deletes the test object.
|
||||
+ impl->os_stack_trace_getter()->UponLeavingGTest();
|
||||
+ internal::HandleExceptionsInMethodIfSupported(
|
||||
+ test, &Test::DeleteSelf_, "the test fixture's destructor");
|
||||
+ }
|
||||
|
||||
result_.set_elapsed_time(internal::GetTimeInMillis() - start);
|
||||
|
@ -1,28 +1,29 @@
|
||||
diff --git a/googlemock/CMakeLists.txt b/googlemock/CMakeLists.txt
|
||||
index 4304995..5ca735b 100644
|
||||
index 8a8de1f..3d86a59 100644
|
||||
--- a/googlemock/CMakeLists.txt
|
||||
+++ b/googlemock/CMakeLists.txt
|
||||
@@ -99,6 +99,9 @@ else()
|
||||
target_link_libraries(gmock_main gmock)
|
||||
@@ -109,8 +109,10 @@ if (MSVC)
|
||||
else()
|
||||
cxx_library(gmock "${cxx_strict}" src/gmock-all.cc)
|
||||
target_link_libraries(gmock PUBLIC gtest)
|
||||
+ set_target_properties(gmock PROPERTIES VERSION 1.8.1)
|
||||
cxx_library(gmock_main "${cxx_strict}" src/gmock_main.cc)
|
||||
target_link_libraries(gmock_main PUBLIC gmock)
|
||||
+ set_target_properties(gmock_main PROPERTIES VERSION 1.8.1)
|
||||
endif()
|
||||
|
||||
+set_target_properties(gmock PROPERTIES VERSION 1.8.0)
|
||||
+set_target_properties(gmock_main PROPERTIES VERSION 1.8.0)
|
||||
+
|
||||
# If the CMake version supports it, attach header directory information
|
||||
# to the targets for when we are part of a parent build (ie being pulled
|
||||
# in via add_subdirectory() rather than being a standalone build).
|
||||
diff --git a/googletest/CMakeLists.txt b/googletest/CMakeLists.txt
|
||||
index ab82f23..97f7554 100644
|
||||
index 9ee7940..8099130 100644
|
||||
--- a/googletest/CMakeLists.txt
|
||||
+++ b/googletest/CMakeLists.txt
|
||||
@@ -88,7 +88,9 @@ endif()
|
||||
@@ -131,7 +131,9 @@ endif()
|
||||
# are used for other targets, to ensure that gtest can be compiled by a user
|
||||
# aggressive about warnings.
|
||||
cxx_library(gtest "${cxx_strict}" src/gtest-all.cc)
|
||||
+set_target_properties(gtest PROPERTIES VERSION 1.8.0)
|
||||
+set_target_properties(gtest PROPERTIES VERSION 1.8.1)
|
||||
cxx_library(gtest_main "${cxx_strict}" src/gtest_main.cc)
|
||||
+set_target_properties(gtest_main PROPERTIES VERSION 1.8.0)
|
||||
target_link_libraries(gtest_main gtest)
|
||||
|
||||
+set_target_properties(gtest_main PROPERTIES VERSION 1.8.1)
|
||||
# If the CMake version supports it, attach header directory information
|
||||
# to the targets for when we are part of a parent build (ie being pulled
|
||||
# in via add_subdirectory() rather than being a standalone build).
|
@ -0,0 +1,17 @@
|
||||
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
|
||||
index 96b07c6..4af3e5a 100644
|
||||
--- a/googletest/src/gtest.cc
|
||||
+++ b/googletest/src/gtest.cc
|
||||
@@ -2693,10 +2693,12 @@ void TestInfo::Run() {
|
||||
test->Run();
|
||||
}
|
||||
|
||||
+ if (test != NULL) {
|
||||
// Deletes the test object.
|
||||
impl->os_stack_trace_getter()->UponLeavingGTest();
|
||||
internal::HandleExceptionsInMethodIfSupported(
|
||||
test, &Test::DeleteSelf_, "the test fixture's destructor");
|
||||
+ }
|
||||
|
||||
result_.set_elapsed_time(internal::GetTimeInMillis() - start);
|
||||
|
@ -1 +1 @@
|
||||
SHA512 (release-1.8.0.tar.gz) = 1dbece324473e53a83a60601b02c92c089f5d314761351974e097b2cf4d24af4296f9eb8653b6b03b1e363d9c5f793897acae1f0c7ac40149216035c4d395d9d
|
||||
SHA512 (release-1.8.1.tar.gz) = e6283c667558e1fd6e49fa96e52af0e415a3c8037afe1d28b7ff1ec4c2ef8f49beb70a9327b7fc77eb4052a58c4ccad8b5260ec90e4bceeac7a46ff59c4369d7
|
||||
|
Loading…
Reference in new issue