Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++11 helgrind未检测到std::mutex的递归锁定_C++11_G++_Deadlock_Valgrind - Fatal编程技术网

C++11 helgrind未检测到std::mutex的递归锁定

C++11 helgrind未检测到std::mutex的递归锁定,c++11,g++,deadlock,valgrind,C++11,G++,Deadlock,Valgrind,我注意到helgrind不会在非递归c++11 std::mutex上检测到递归锁。但是,在使用pthread_mutex_lock时会检测到该问题 演示问题的两个简单测试用例: // Test code: C++11 std::mutex // helgrind does not detect recursive locking void test_cpp11() { std::mutex m; m.lock(); m.lock(); } gdb显示正在调用相同的p

我注意到helgrind不会在非递归c++11 std::mutex上检测到递归锁。但是,在使用pthread_mutex_lock时会检测到该问题

演示问题的两个简单测试用例:

// Test code: C++11 std::mutex
// helgrind does not detect recursive locking
void test_cpp11()
{
    std::mutex m;
    m.lock();
    m.lock();
}

gdb显示正在调用相同的pthread库函数:

#0  __lll_lock_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135
#1  0x00007ffff78c2657 in _L_lock_909 () from /lib/x86_64-linux-gnu/libpthread.so.0
#2  0x00007ffff78c2480 in __GI___pthread_mutex_lock (mutex=0x7fffffffe450) at ../nptl/pthread_mutex_lock.c:79
#3  0x00000000004008ad in test_pth() ()

这是在Ubuntu 14.04 64位上的g++4.7.3、4.8.2和4.9.0中观察到的


有没有人知道是什么原因导致helgrind检测到递归锁定?有没有人知道该怎么做?

不是对原始问题的回答,但我认为值得一提的是,应该始终使用和检查程序。
drd
工具在两种情况下都成功检测到问题。

好的,这很有趣。我不知何故(出于习惯)专注于Helgink,从来没有真正使用DRD,甚至没有考虑过这个问题。但这确实是一个帮助。在我看来,这就像是地狱里的一只虫子。我将尝试进一步调查,也许会提交一个bug。
#0  __lll_lock_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135
#1  0x00007ffff78c2657 in _L_lock_909 () from /lib/x86_64-linux-gnu/libpthread.so.0
#2  0x00007ffff78c2480 in __GI___pthread_mutex_lock (mutex=0x7fffffffe450) at ../nptl/pthread_mutex_lock.c:79
#3  0x00000000004008ad in test_pth() ()
#1  0x00007ffff78c2657 in _L_lock_909 () from /lib/x86_64-linux-gnu/libpthread.so.0
#2  0x00007ffff78c2480 in __GI___pthread_mutex_lock (mutex=0x7fffffffe450) at ../nptl/pthread_mutex_lock.c:79
#3  0x00000000004007f7 in __gthread_mutex_lock(pthread_mutex_t*) ()
#4  0x00000000004008ec in std::mutex::lock() ()
#5  0x0000000000400857 in test_cpp11() ()