为什么pthread_mutex_t在gdb中构造全零?

时间:2019-10-21 18:29:08

标签: linux arm gdb mutex glibc

是什么导致pthread_mutex_t结构全为零? gdb会话中死锁的ARM测试应用程序的核心:

[Switching to thread 3 (LWP 3587)]
#0  __lll_lock_wait (futex=futex@entry=0x2105c <one_mutex>, private=0) at lowlevellock.c:46
46  lowlevellock.c: No such file or directory.
(gdb) f 1
#1  0xaf973818 in __GI___pthread_mutex_lock (mutex=0x2105c <one_mutex>) at pthread_mutex_lock.c:81
81  pthread_mutex_lock.c: No such file or directory.
(gdb) p mutex
$1 = (pthread_mutex_t *) 0x2105c <one_mutex>
(gdb) p (pthread_mutex_t ) 0x2105c
$2 = {
  __data = {
    __lock = 0,
    __count = 0,
    __owner = 0,
    __kind = 0,
    __nusers = 0,
    {
      __spins = 0,
      __list = {
        __next = 0x0
      }
    }
  },
  __size = '\000' <repeats 23 times>,
  __align = 0
}

1 个答案:

答案 0 :(得分:0)

pthread_mutex_t用于所有互斥锁类型,其某些成员仅用于特定的互斥锁类型。

为至少以下互斥类型设置了

owner成员:

  • PTHREAD_MUTEX_ERRORCHECK_NP
  • PTHREAD_MUTEX_RECURSIVE_NP

有关更多详细信息,请参见glibc implementation of pthread_mutex_trylock