Qt调试:我如何知道QCoreApplication::notifyInternal2正在向哪个对象发送消息?
Qt debugging: How can I know which object QCoreApplication::notifyInternal2 is sending a message to?
我有一个在另一个线程中运行QtCoreApplication的Windows服务。当服务停止时,程序总是崩溃。Qt似乎正在向已被清理的对象发送事件。
虽然我很确定我使用 deleteLater 清理所有对象。幸运的是,gdb 给了我输出,说程序在 notifyInternal2 上崩溃,这提示我崩溃是如何发生的。
但实际上,我很想知道崩溃发生在哪里。Qt中是否有调试日志级别,或者是否有一种方法可以判断事件尝试发送到哪个事件或哪个对象?
GDB 输出
Thread 4 received signal SIGSEGV, Segmentation fault.
[Switching to Thread 3492.0x980]
QCoreApplication::notifyInternal2 (receiver=0x2724bdd0,
event=event@entry=0x1a33e48) at kernel/qcoreapplication.cpp:1047
1047 kernel/qcoreapplication.cpp: No such file or directory.
(gdb) bt
#0 QCoreApplication::notifyInternal2 (receiver=0x2724bdd0,
event=event@entry=0x1a33e48) at kernel/qcoreapplication.cpp:1047
#1 0x01f91ef2 in QCoreApplication::sendEvent (event=0x1a33e48,
receiver=<optimized out>)
at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:234
#2 QCoreApplicationPrivate::sendPostedEvents (receiver=<optimized out>,
receiver@entry=0x0, event_type=<optimized out>, event_type@entry=52,
data=<optimized out>) at kernel/qcoreapplication.cpp:1740
#3 0x01f92579 in QCoreApplication::sendPostedEvents (
receiver=receiver@entry=0x0, event_type=event_type@entry=52)
at kernel/qcoreapplication.cpp:1594
#4 0x01f925ad in QCoreApplicationPrivate::execCleanup (this=0x19a4b38)
at kernel/qcoreapplication.cpp:1360
#5 0x01f93dec in QCoreApplication::exec ()
at kernel/qcoreapplication.cpp:1342
#6 0x004277bc in qtservice::windows::Handler::startup (this=0x19a8ce8,
argc=1, argv=0x1d3a9e8, service_status_handle=0x1d32c88)
at C:UsersmichaelDocumentsdevcppconnectlibQtServiceWindowsHandler.cpp:156
#7 0x004253f3 in qtservice::windows::Service::startup (this=0x28fe3c,
argc=1, argv=0x1d3a9e8)
at C:UsersmichaelDocumentsdevcppconnectlibQtServiceWindowsService.cpp:141
#8 0x004252b6 in qtservice::windows::Service::serviceMain(unsigned long, wchar_t**)@8 (argc=1, argv=0x1d3a9e8)
at C:UsersmichaelDocumentsdevcppconnectlibQtServiceWindowsService.cpp:100
#9 0x75a375a8 in SECHOST!I_ScIsSecurityProcess ()
from C:WindowsSysWOW64sechost.dll
#10 0x00000001 in ?? ()
#11 0x01d3a9e8 in ?? ()
#12 0x7715343d in KERNEL32!BaseThreadInitThunk ()
from C:Windowssyswow64kernel32.dll
#13 0x77879832 in ntdll!RtlInitializeExceptionChain ()
from C:WindowsSysWOW64ntdll.dll
#14 0x77879805 in ntdll!RtlInitializeExceptionChain ()
from C:WindowsSysWOW64ntdll.dll
#15 0x00000000 in ?? ()
Qt从不向被破坏的对象发送事件。如果是这样,那么这是另一个问题的症状:其他东西已经损坏了应用程序的状态。也许对象位于过早释放的内存区域中,因此对象本身从未被破坏,但它所在的内存是。
相关文章:
- 如何处理从一个对象传递到另一个在C++中具有公共抽象类的对象的消息
- Qt调试:我如何知道QCoreApplication::notifyInternal2正在向哪个对象发送消息?
- 封装和消息对象
- 错误消息:不允许抽象类类型 "X" 的对象:纯虚拟"Y"没有覆盖器
- MFC编辑控制消息处理访问文档对象
- 为什么我在 gdb 中收到 ifstream 对象的<不完整类型>消息?
- 如何向创建对象的类发送消息
- 如何在 MPI 中的 std::map 等C++中传递 STL 对象的消息
- 使用智能指针在窗口消息中将对象作为 WPARAM 传递
- 对对象大小的“static_assert”更好的消息
- 当对象 A 想要向对象 B 发送消息时,该方法应位于何处
- C++对象函数错误消息
- 使用互斥对象与消息在线程之间共享信息
- 如果对象将在消息处理程序中使用,如何解决内存泄漏问题
- 视觉对象C++窗体、简单消息框和将文本从文本字段分配给字符串时出错
- 如何在不将字符串对象嵌入自定义异常类的情况下重新格式化错误消息
- 预序列化消息对象-实现
- std::使用来自本地对象的消息时发生异常
- 发送消息中的对象
- 在两个对象之间发送消息