QMutex :: lock:在线程0xfe8(主线程?)中检测到死锁

时间:2011-04-28 05:49:07

标签: multithreading qt thread-safety

我在GDB中运行我的程序。我的程序需要为其工作创建16个线程。这一切都很好。最后我收到错误QMutex::lock: Deadlock detected in thread 0xfe8 这是GDB输出

(gdb) run
Starting program: C:\dgrfb.run\client/DGRFB.exe
[New thread 4076.0xfe8]
[New thread 4076.0x368]
warning: >> Socket State Changed:  QAbstractSocket::HostLookupState
warning: >> Socket State Changed:  QAbstractSocket::ConnectingState
[New thread 4076.0x4b8]
warning: >> Socket State Changed:  QAbstractSocket::ConnectedState
[New thread 4076.0x49c]
warning: Rect Area 0 2 DG::UpdateThread(0xa0d5220)
warning: Rect Area 0 3 DG::UpdateThread(0xa0d5548)
warning: Rect Area 1 0 DG::UpdateThread(0xa0d5870)
warning: Rect Area 1 1 DG::UpdateThread(0xa0d5b98)
warning: Rect Area 1 2 DG::UpdateThread(0xa0d5ec0)
warning: Rect Area 1 3 DG::UpdateThread(0xa0d61e8)
warning: Rect Area 2 0 DG::UpdateThread(0xa0d6510)
warning: Rect Area 2 1 DG::UpdateThread(0xa0d6838)
warning: Rect Area 2 2 DG::UpdateThread(0xa0d6b60)
warning: Rect Area 2 3 DG::UpdateThread(0xa0d6e88)
[New thread 4076.0x540]
warning: Rect Area 3 0 DG::UpdateThread(0xa0d71b0)
warning: Rect Area 3 1 DG::UpdateThread(0xa0d7568)
warning: Rect Area 3 2 DG::UpdateThread(0xa0d7cc0)
warning: Rect Area 3 3 DG::UpdateThread(0xa0d7fe8)
[New thread 4076.0x670]
[New thread 4076.0x6dc]
[New thread 4076.0x674]
[New thread 4076.0x3ac]
[New thread 4076.0x684]
[New thread 4076.0x434]
[New thread 4076.0x44c]
[New thread 4076.0x7e8]
[New thread 4076.0x408]
[New thread 4076.0x7e0]
[New thread 4076.0x42c]
[New thread 4076.0x814]
[New thread 4076.0x6f8]
[New thread 4076.0x8a4]
warning: QThread(0x3d58d8) tick
warning: Rect #  0 0 100 56
warning:                 Unmatched true
warning:                 Updating  0 0
warning: QMutex::lock: Deadlock detected in thread 0xfe8

现在哪个帖子0xfe8是?它是主线程吗? 首先,我以为我已经两次调用相同的mutex.lock()。或func_a()func_b()使用相同的互斥锁。这就是造成僵局的原因。但是没有发现任何这种情况。那么开始调查了吗?

2 个答案:

答案 0 :(得分:0)

很难回答哪个线程导致死锁。但是,根据经验,尝试使用QMutexLocker尽可能避免死锁。这样您的静音就会自动解锁。

答案 1 :(得分:0)

当我尝试从相同的thead锁定互斥锁两次时,我看到了这条消息。让QMutex recursive修复它。

相关问题