Drd - 如何解释此 "Other segment" 调用堆栈?

Drd - How to interpret this "Other segment" call stack?

我 运行 drd 在一些遗留代码中捕捉数据竞争。我知道 drd 适用于段而不是单个指令,我期待在 的调用堆栈之间找到 共同点 其他段开始其他段结束,但事实并非如此。

==12982== Thread 5:
==12982== Conflicting load by thread 5 at 0x0060e6b0 size 8
==12982==    at 0x4F2CBEB: std::_Rb_tree<int, std::pair<int const, CMNSSrvNesting*>, std::_Select1st<std::pair<int const, CMNSSrvNesting*> >, std::less<int>, std::allocator<std::pair<int const, CMNSSrvNesting*> > >::find(int const&) (stl_tree.h:502)
==12982==    by 0x4F27FBE: CMetiMNSSrv::GetSockDataPtr(int, int) (stl_map.h:822)
==12982==    by 0x4F2A8E2: CMetiMNSSrv::ServerMessagesHandler(t_blkLx, unsigned char*, CAsyncSocketL*, void*) (MetiMNSSrv.cpp:957)
==12982==    by 0x507A705: CAsyncSocketL::SockHandlerCallback(void*, t_blkLx*, unsigned char*) (TWSocketLinux.cpp:417)
==12982==    by 0x518F2D1: _SK_Connection_handler (twlsocket.c:434)
==12982==    by 0x4C30E7B: ??? (in /usr/lib/valgrind/vgpreload_drd-amd64-linux.so)
==12982==    by 0x685F181: start_thread (pthread_create.c:312)
==12982==    by 0x6B6F47C: clone (clone.S:111)
==12982== Allocation context: BSS section of /home/teseo/bin/LiMNEGUI/LiMNEGUI
==12982== Other segment start (thread 4)
==12982==    at 0x4C34544: pthread_mutex_unlock (in /usr/lib/valgrind/vgpreload_drd-amd64-linux.so)
==12982==    by 0x5135589: pthreadMutexLeave (sqlite3.c:18998)
==12982==    by 0x5122E3F: sqlite3_mutex_leave (sqlite3.c:18451)
==12982==    by 0x5123321: sqlite3_free (sqlite3.c:19929)
==12982==    by 0x5168349: sqlite3LeaveMutexAndCloseZombie (sqlite3.c:122082)
==12982==    by 0x51685A4: sqlite3Close (sqlite3.c:121948)
==12982==    by 0x51685C5: sqlite3_close (sqlite3.c:121961)
==12982==    by 0x518FA7F: Sqlite3Db::~Sqlite3Db() (twnestshared.cpp:89)
==12982==    by 0x519A346: CIniFile::SetValue(std::string const&, std::string const&, std::string const&, std::string const&) (twnestshared.cpp:1264)
==12982==    by 0x519B148: CMetiReg::SerialItem(char const*, unsigned int*, unsigned int, char const*) (twnestshared.cpp:1431)
==12982==    by 0x4F22D6F: CMetiMNSSrv::SetRegistryVal(char const*, char const*, unsigned int, bool) (MetiMNSSrv.cpp:72)
==12982==    by 0x4F24BAE: CMNSSrvNesting::SetLastOperationTime(bool, unsigned int, unsigned long long, unsigned long long) (MetiMNSSrv.cpp:616)
==12982== Other segment end (thread 4)
==12982==    at 0x68667EB: recv (recv.c:33)
==12982==    by 0x518E736: SK_GetBytes (socket2.h:44)
==12982==    by 0x518E8D6: SK_GetBlock (twlsocket.c:858)
==12982==    by 0x518F19D: _SK_Connection_handler (twlsocket.c:407)
==12982==    by 0x4C30E7B: ??? (in /usr/lib/valgrind/vgpreload_drd-amd64-linux.so)
==12982==    by 0x685F181: start_thread (pthread_create.c:312)
==12982==    by 0x6B6F47C: clone (clone.S:111)

我应该如何解读这些信息?我在哪里可以找到 thread 4thread 5 冲突的点?

编辑:其他信息

程序已使用 GCC 4.8 编译,调试信息 -g3 和优化 -Og

drd 无法在另一个线程中给出冲突的准确位置。

上面drd错误输出中,2段start/end限制为12 默认情况下程序计数器。您可以使用 选项 --num-callers=

如果你想得到更准确的信息,你可以试试 --tool=helgrind 可以记录竞争中涉及的两个线程的精确堆栈跟踪。 但是,对于 helgrind,'other thread' 堆栈跟踪限制为 8 程序计数器(而 'first thread' 堆栈跟踪类似 受 --num-callers=

限制