google / google/googletest

mutex->__data.__owner == 0

Open
#2,173 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
39.5k
Forks
10.9k
Avg merge
6d 13h
Merged PRs (30d)
1

Description

Hi,

we are using gtest 1.8.0 and added a patch for #1817. On gcc 6.3.0 we now see issues with mutexes in gtest's linked lists:

```
0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#1 0x00007ffff66c102a in __GI_abort () at abort.c:89
#2 0x00007ffff66b7bd7 in __assert_fail_base (fmt=, assertion=assertion@entry=0x7ffff730a015 "mutex->__data.__owner == 0",
file=file@entry=0x7ffff7309ff8 "../nptl/pthread_mutex_lock.c", line=line@entry=81,
function=function@entry=0x7ffff730a180 <__PRETTY_FUNCTION__.8623> "__pthread_mutex_lock") at assert.c:92
#3 0x00007ffff66b7c82 in __GI___assert_fail (assertion=assertion@entry=0x7ffff730a015 "mutex->__data.__owner == 0",
file=file@entry=0x7ffff7309ff8 "../nptl/pthread_mutex_lock.c", line=line@entry=81,
function=function@entry=0x7ffff730a180 <__PRETTY_FUNCTION__.8623> "__pthread_mutex_lock") at assert.c:101
#4 0x00007ffff7300f68 in __GI___pthread_mutex_lock (mutex=) at ../nptl/pthread_mutex_lock.c:81
#5 0x0000000000d09107 in testing::internal::MutexBase::Lock (this=0x2258d40 )
at /home/svn/process-frames/src/../target/references/include/gtest/internal/gtest-port.h:2061
#6 0x0000000000d0928a in testing::internal::GTestMutexLock::GTestMutexLock (this=0x7fffffffd9a0,
mutex=0x2258d40 )
at /home/svn/process-frames/src/../target/references/include/gtest/internal/gtest-port.h:2137
#7 0x0000000000d092f2 in testing::internal::linked_ptr_internal::join (this=0x7fffffffdb38, ptr=0x227c658)
at /home/svn/process-frames/src/../target/references/include/gtest/internal/gtest-linked_ptr.h:110
#8 0x0000000000d202c5 in testing::internal::linked_ptr::TestInfo>::copy::TestInfo> (this=0x7fffffffdb30, ptr=0x227c650)
at /home/svn/process-frames/src/../target/references/include/gtest/internal/gtest-linked_ptr.h:216
#9 0x0000000000d1caa4 in testing::internal::linked_ptr::TestInfo>::linked_ptr (this=0x7fffffffdb30, ptr=...) at /home/svn/process-frames/src/../target/references/include/gtest/internal/gtest-linked_ptr.h:159
#10 0x0000000000d28d57 in testing::internal::ParameterizedTestCaseInfo::RegisterTests (this=0x227c3b0)
at /home/svn/process-frames/src/../target/references/include/gtest/internal/gtest-param-util.h:544
#11 0x0000000000db258e in testing::internal::ParameterizedTestCaseRegistry::RegisterTests (this=0x22720e0)
at /home/jenkins/workspace/com.google.gtest-linux-x86_64-gcc6-parameterized/src/googletest/include/gtest/internal/gtest-param-util.h:709
#12 0x0000000000d9a18e in testing::internal::UnitTestImpl::RegisterParameterizedTests (this=0x2271fd0)
at /home/jenkins/workspace/com.google.gtest-linux-x86_64-gcc6-parameterized/src/googletest/src/gtest.cc:2658
#13 0x0000000000da4df5 in testing::internal::UnitTestImpl::PostFlagParsingInit (this=0x2271fd0)
at /home/jenkins/workspace/com.google.gtest-linux-x86_64-gcc6-parameterized/src/googletest/src/gtest.cc:4980
#14 0x0000000000dbdc8b in testing::internal::InitGoogleTestImpl (argc=0x7fffffffde5c, argv=0x7fffffffdf48)
at /home/jenkins/workspace/com.google.gtest-linux-x86_64-gcc6-parameterized/src/googletest/src/gtest.cc:5934
#15 0x0000000000da7524 in testing::InitGoogleTest (argc=0x7fffffffde5c, argv=0x7fffffffdf48)
at /home/jenkins/workspace/com.google.gtest-linux-x86_64-gcc6-parameterized/src/googletest/src/gtest.cc:5952
#16 0x0000000000d76639 in main (argc=1, argv=0x7fffffffdf48)
at /home/jenkins/workspace/com.google.gtest-linux-x86_64-gcc6-parameterized/src/googletest/src/gtest_main.cc:35
```

What I can see: gtest starts with the main function from gtest_main, but some mutex of a linked list is either not initialized or already destructed when the unit tests are registered.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the failure with GoogleTest 1.8.0, GCC 6.3.0, and parameterized tests. Read the linked-list mutex code in gtest-linked_ptr.h and gtest-port.h, then trace registration through gtest-param-util.h and gtest.cc. Done means parameterized test registration no longer triggers the pthread mutex assertion.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.