Project

General

Profile

Bug #1911

some internal unit tests fail with segmentation fault in gmock

Added by Dominik Mierzejewski over 4 years ago. Updated about 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
Affected version - extra info:
a7093a73959458a1f4aa4e384104a5515a4f2863
Affected version:
Difficulty:
uncategorized
Close

Description

While running the internal testsuite (make check) of git snapshot a7093a73959458a1f4aa4e384104a5515a4f2863, I'm getting segmentation faults in the following tests:

      1 - TestUtilsUnitTests (SEGFAULT)
      3 - CommandLineUnitTests (SEGFAULT)
      8 - OnlineHelpUnitTests (SEGFAULT)
      9 - OptionsUnitTests (SEGFAULT)

Here is a sample backtrace from the first test:
[mockbuild@7722349c388e4813b90b5278b3a9f257 openmpi]$ LD_LIBRARY_PATH=/builddir/build/BUILDROOT/gromacs-2016-0.1.20160224gita7093a7.fc24.x86_64/usr/lib64/openmpi/lib gdb bin/testutils-test 
GNU gdb (GDB) Fedora 7.10.90.20160216-54.fc24
...
Reading symbols from bin/testutils-test...done.
(gdb) run
Starting program: /builddir/build/BUILD/gromacs-a7093a73959458a1f4aa4e384104a5515a4f2863/openmpi/bin/testutils-test 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 0x7ffff050b700 (LWP 123)]
[==========] Running 43 tests from 5 test cases.
[----------] Global test environment set-up.
[----------] 10 tests from InteractiveTestHelperTest
[ RUN      ] InteractiveTestHelperTest.ChecksSimpleSession

Thread 1 "testutils-test" received signal SIGSEGV, Segmentation fault.
testing::internal::FunctionMockerBase<void (char const*)>::InvokeWith(std::tuple<char const*> const&) (
    args=std::tuple containing = {...}, this=0x94a890)
    at /builddir/build/BUILD/gromacs-a7093a73959458a1f4aa4e384104a5515a4f2863/src/external/gmock-1.7.0/include/gmock/gmock-spec-builders.h:1530
1530            this->UntypedInvokeWith(&args))->GetValueAndDelete();
(gdb) where
#0  testing::internal::FunctionMockerBase<void (char const*)>::InvokeWith(std::tuple<char const*> const&) (
    args=std::tuple containing = {...}, this=0x94a890)
    at /builddir/build/BUILD/gromacs-a7093a73959458a1f4aa4e384104a5515a4f2863/src/external/gmock-1.7.0/include/gmock/gmock-spec-builders.h:1530
#1  testing::internal::FunctionMocker<void (char const*)>::Invoke(char const*) (a1=0x4aba38 "First line\n", 
    this=0x94a890)
    at /builddir/build/BUILD/gromacs-a7093a73959458a1f4aa4e384104a5515a4f2863/src/external/gmock-1.7.0/include/gmock/gmock-generated-function-mockers.h:97
#2  gmx::test::MockTextOutputStream::write (this=this@entry=0x94a888, gmock_a1=0x4aba38 "First line\n")
    at /builddir/build/BUILD/gromacs-a7093a73959458a1f4aa4e384104a5515a4f2863/src/testutils/interactivetest.cpp:78
#3  0x000000000042f0ba in (anonymous namespace)::InteractiveSession::run (this=0x7fffffffd4e0)
    at /builddir/build/BUILD/gromacs-a7093a73959458a1f4aa4e384104a5515a4f2863/src/testutils/tests/interactivetest.cpp:100
#4  (anonymous namespace)::InteractiveTestHelperTest_ChecksSimpleSession_Test::TestBody (this=<optimized out>)
    at /builddir/build/BUILD/gromacs-a7093a73959458a1f4aa4e384104a5515a4f2863/src/testutils/tests/interactivetest.cpp:152
#5  0x00000000004ab1d4 in testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void> (
    location=0x4b4d42 "the test body", method=<optimized out>, object=<optimized out>)
    at /builddir/build/BUILD/gromacs-a7093a73959458a1f4aa4e384104a5515a4f2863/src/external/gmock-1.7.0/gtest/src/gtest.cc:2078
#6  testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void> (object=object@entry=0x782cc0, 
    method=<optimized out>, location=location@entry=0x4b4d42 "the test body")
    at /builddir/build/BUILD/gromacs-a7093a73959458a1f4aa4e384104a5515a4f2863/src/external/gmock-1.7.0/gtest/src/gtest.cc:2114
#7  0x00000000004a135a in testing::Test::Run (this=this@entry=0x782cc0)
    at /builddir/build/BUILD/gromacs-a7093a73959458a1f4aa4e384104a5515a4f2863/src/external/gmock-1.7.0/gtest/src/gtest.cc:2151
#8  0x00000000004a1555 in testing::Test::Run (this=0x782cc0)
    at /builddir/build/BUILD/gromacs-a7093a73959458a1f4aa4e384104a5515a4f2863/src/external/gmock-1.7.0/gtest/src/gtest.cc:2142
#9  testing::TestInfo::Run (this=0x6eb4c0)
    at /builddir/build/BUILD/gromacs-a7093a73959458a1f4aa4e384104a5515a4f2863/src/external/gmock-1.7.0/gtest/src/gtest.cc:2326
#10 0x00000000004a16e5 in testing::TestInfo::Run (this=<optimized out>)
    at /builddir/build/BUILD/gromacs-a7093a73959458a1f4aa4e384104a5515a4f2863/src/external/gmock-1.7.0/gtest/src/gtest.cc:2301
#11 testing::TestCase::Run (this=0x6eba60)
    at /builddir/build/BUILD/gromacs-a7093a73959458a1f4aa4e384104a5515a4f2863/src/external/gmock-1.7.0/gtest/src/gtest.cc:2444
#12 0x00000000004a1e6d in testing::TestCase::Run (this=<optimized out>)
    at /builddir/build/BUILD/gromacs-a7093a73959458a1f4aa4e384104a5515a4f2863/src/external/gmock-1.7.0/gtest/src/gtest.cc:2430
#13 testing::internal::UnitTestImpl::RunAllTests (this=0x6eb600)
    at /builddir/build/BUILD/gromacs-a7093a73959458a1f4aa4e384104a5515a4f2863/src/external/gmock-1.7.0/gtest/src/gtest.cc:4315
#14 0x00000000004ab6b4 in testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> (location=0x4b4368 "auxiliary test code (environments or event listeners)", method=<optimized out>, 
    object=<optimized out>)
    at /builddir/build/BUILD/gromacs-a7093a73959458a1f4aa4e384104a5515a4f2863/src/external/gmock-1.7.0/gtest/src/gtest.cc:2078
#15 testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> (object=0x6eb600, 
    method=<optimized out>, location=location@entry=0x4b4368 "auxiliary test code (environments or event listeners)")
    at /builddir/build/BUILD/gromacs-a7093a73959458a1f4aa4e384104a5515a4f2863/src/external/gmock-1.7.0/gtest/src/gtest.cc:2114
#16 0x00000000004a25e9 in testing::UnitTest::Run (this=0x6d48a0 <testing::UnitTest::GetInstance()::instance>)
    at /builddir/build/BUILD/gromacs-a7093a73959458a1f4aa4e384104a5515a4f2863/src/external/gmock-1.7.0/gtest/src/gtest.cc:3926
#17 0x000000000042a695 in RUN_ALL_TESTS ()
    at /builddir/build/BUILD/gromacs-a7093a73959458a1f4aa4e384104a5515a4f2863/src/external/gmock-1.7.0/gtest/include/gtest/gtest.h:2290
#18 main (argc=<optimized out>, argv=<optimized out>)
    at /builddir/build/BUILD/gromacs-a7093a73959458a1f4aa4e384104a5515a4f2863/src/testutils/unittest_main.cpp:65
(gdb) 

Environment: Fedora rawhide (24).
Package versions:
Random123-devel-1.08-4.fc24.noarch
atlas-devel-3.10.2-12.fc24.x86_64
boost-devel-1.60.0-4.fc24.x86_64
cmake-3.5.0-0.2.rc3.fc24.x86_64
fftw-devel-3.3.4-7.fc24.x86_64
gcc-6.0.0-0.12.fc24.x86_64
gsl-devel-2.1-1.fc24.x86_64
libX11-devel-1.6.3-3.fc24.x86_64
libxml2-devel-2.9.3-3.fc24.x86_64
lmfit-devel-6.1-2.fc24.x86_64
motif-devel-2.3.4-11.fc24.x86_64
openmpi-devel-1.10.2-3.fc24.x86_64

Associated revisions

Revision d6e35c96 (diff)
Added by Erik Lindahl over 4 years ago

Fix unit test segfaults with gcc-6.0

Work around a bug in gmock-1.7 by adding the flag
-fno-delete-null-pointer-checks to for the gmock
and testutil sources.

Fixes #1911.

Change-Id: I3e2d3fde99898191437d9eed986659f6f6fb056a

Revision 398305ea (diff)
Added by Mark Abraham over 4 years ago

Improve handling of gmock and gcc6

This patch reverts commit d6e35c96 that used gcc
-fno-delete-null-pointer-checks to work around implementation errors
in gmock 1.7. There's been no new release of gmock for several years,
but a patch is now available to address this issue.

This commit applies that patch, found at
https://github.com/google/googletest/issues/705#issuecomment-235067917. Updated
our README describing modifications GROMACS has found it necessary to
make.

Fixes #1911

Change-Id: I0d5abe9bf8172f6749bcad97a13765edaa3d4c80

History

#1 Updated by Mark Abraham over 4 years ago

These are all using features of Google Mock 1.7 in the test harness (only). These require a working std::tuple. I see that you're doing pre-release testing of gcc 6 - perhaps there's some stdlib incompatibilities involved. I did a build myself the other week, but suspect I didn't actually run the unit tests.

Are other packages that use Google Mock reporting issues? Google Mock has its own tr1::tuple implementation that is available as a fallback if the real issue isn't solved.

#2 Updated by Dominik Mierzejewski over 4 years ago

Mark Abraham wrote:

These are all using features of Google Mock 1.7 in the test harness (only). These require a working std::tuple. I see that you're doing pre-release testing of gcc 6 - perhaps there's some stdlib incompatibilities involved. I did a build myself the other week, but suspect I didn't actually run the unit tests.

I suspected this might be related to gcc 6 upgrade in the upcoming Fedora 24, but I didn't have any leads. Thanks for the hint, I'll try to investigate along that line.

Are other packages that use Google Mock reporting issues? Google Mock has its own tr1::tuple implementation that is available as a fallback if the real issue isn't solved.

No idea, to be honest. I think it's worth highlighting that gmock 1.7.0 is old and has since been merged (see https://github.com/google/googlemock) into Google Test framework, which is actively developed. Maybe it's time to update the bundled copy?

#4 Updated by Dominik Mierzejewski over 4 years ago

Compiling with -fno-delete-null-pointer-checks doesn't help, unfortunately, so it might not be the same bug as above.

#5 Updated by Teemu Murtola over 4 years ago

Dominik Mierzejewski wrote:

No idea, to be honest. I think it's worth highlighting that gmock 1.7.0 is old and has since been merged (see https://github.com/google/googlemock) into Google Test framework, which is actively developed. Maybe it's time to update the bundled copy?

Yes, it's "old", but it's also the latest release... There is no official release of the combined framework at all, so this isn't particularly active, either. It hardly makes a difference between having one or two repositories, when in practise the coupling between the two is still exactly the same as it was earlier.

#6 Updated by Mark Abraham over 4 years ago

  • Status changed from New to Blocked, need info

Dominik Mierzejewski wrote:

It looks like it's a bug in googletest: https://github.com/google/googletest/issues/705 , also reported in Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=812289 .

Thanks for finding those. I have also reproduced your issues with my Arch-based gcc-6 pre-release. It didn't matter how I set up dynamic linking paths to get system or gcc-6 stdlib.

I realize Dominik didn't get it to work, but from the experience of a couple of other projects reported at https://github.com/google/googletest/issues/705, I still expect that -fno-delete-null-pointer-checks (e.g. https://github.com/ampl/mp/commit/9fdb5147068f3b719999210e56b493327f1ca5e7) may be a workaround we may need to apply, but we can wait a few weeks before addressing this, to see if a canonical fix emerges.

#7 Updated by Dominik Mierzejewski over 4 years ago

Correction: I finally managed to quash all segfaults in gmock by ensuring everything is built with -fno-delete-null-pointer-checks. So adding a work around to CMakeLists.txt for the time being might be a good idea.

#8 Updated by Gerrit Code Review Bot over 4 years ago

Gerrit received a related patchset '1' for Issue #1911.
Uploader: Erik Lindahl ()
Change-Id: I3e2d3fde99898191437d9eed986659f6f6fb056a
Gerrit URL: https://gerrit.gromacs.org/5774

#9 Updated by Erik Lindahl over 4 years ago

  • Status changed from Blocked, need info to Fix uploaded

#10 Updated by Erik Lindahl over 4 years ago

  • Status changed from Fix uploaded to Resolved

#12 Updated by Erik Lindahl over 4 years ago

  • Status changed from Resolved to Closed

#13 Updated by Dominik Mierzejewski over 4 years ago

Dominik Mierzejewski wrote:

Correction: I finally managed to quash all segfaults in gmock by ensuring everything is built with -fno-delete-null-pointer-checks. So adding a work around to CMakeLists.txt for the time being might be a good idea.

It looks like it was fixed upstream in https://github.com/google/googletest/commit/b5c81098a8ccc25e313ffca56c911200b3591ea0 in 2014, though no release was made that contains the fix. Actually, no release was made since 2013. Romain Geissler provided a patch against gmock-1.7.0 in https://github.com/google/googletest/issues/705#issuecomment-235067917, so I'd suggest backporting it to GROMACS' gmock copy and reverting the changeset above.

#14 Updated by Mark Abraham over 4 years ago

  • Status changed from Closed to Accepted

Thanks - that patch looks like a better solution!

#15 Updated by Mark Abraham over 4 years ago

  • Target version set to 2016

#16 Updated by Gerrit Code Review Bot over 4 years ago

Gerrit received a related patchset '3' for Issue #1911.
Uploader: Mark Abraham ()
Change-Id: I0d5abe9bf8172f6749bcad97a13765edaa3d4c80
Gerrit URL: https://gerrit.gromacs.org/6064

#17 Updated by Mark Abraham over 4 years ago

  • Status changed from Accepted to Resolved

#18 Updated by Mark Abraham about 4 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF