-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix double free when building Gtest/GMock in shared libraries and lin… #1339
Fix double free when building Gtest/GMock in shared libraries and lin… #1339
Conversation
…king a test executable with both.
Note: the build failed on 2 OS X hosts in the Travis jobs, but this is certainly not due to this pull request. If fails the same way on the last commit of branch master. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for looking at this 👍
"${gtest_dir}/src/gtest-all.cc" | ||
src/gmock-all.cc | ||
src/gmock_main.cc) | ||
if (MSVC) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it necessary to keep doing it that way for MSVC? Wouldn't the target_link_libraries
way work fine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently not if I believe #1286. But the original build issue seems not available anymore. I have honestly not tried myself (and don't have any Windows machine beyond the continuous integration ones).
@Romain-Geissler Please |
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}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously gmock_use_own_tuple_test
was also built with non-MSVC compiler.
I have tested changed version of this patch with gmock_use_own_tuple_test
building enabled on GNU/Linux with GCC and gmock_use_own_tuple_test
test passed.
I think that these 2 lines should be copied to non-MSVC branch below.
This patch fixes tests of Protobuf, which otherwise fail with segmentation fault and abort. |
Thank you again for this. Could you please provide testing evidence to prove that this in fact "This patch fixes tests of Protobuf, which otherwise fail with segmentation fault and abort" |
This was reproduced by both Toralf Förster and me: From Toralf Förster's log in the latter bug:
(I got the same results.) Romain Geissler's patch has been added to dev-cpp/gtest (in version 1.8.0-r1) in Gentoo yesterday. Toralf Förster was using older, unpatched version 1.8.0 of dev-cpp/gtest. |
Summary: Previously to use gmock you simply needed to link against libgmock_main. However, googletest pull request #1339 was recently merged into upstream googletest: google/googletest#1339 These changes now require explicitly linking against libgmock_main, libgmock, and libgtest. Reviewed By: yfeldblum Differential Revision: D6794709 fbshipit-source-id: 03dcccec966e62240987ee0051dfa87be8614cca
The doublefree bug is fixed upstream with the merge of google/googletest#1339 Package-Manager: Portage-2.3.49, Repoman-2.3.10
The doublefree bug is fixed upstream with the merge of google/googletest#1339 Package-Manager: Portage-2.3.49, Repoman-2.3.10
Includes fix for double free bug (google/googletest#1339). Change-Id: I4b79f3f79ff376359b213c7c86e1132f58826379
…king a test executable with both.
Hi,
This fixes issue #930. It is based on what was done in PR #1286 which itself was based on PR #1059 .
The only change from #1286 is that in the tests, the shared library gmock_shared_main is not modified at all, so that the build can go on, and tests are not broken. Tested locally, it fixes the core dump people have when linking both gmock and gtest using shared libraries.
Cheers,
Romain