重现 Qt 中的错误:调试代码时出现分段错误
我对 Linux、Qt 很陌生,对 C++ 也比较初级;所以我遇到的问题很可能是我自己的错......非常感谢任何帮助。
当我尝试在基本上任何项目中逐步进行时,都会遇到分段错误。例如,QtCreator 中包含的tablemodel 项目。在发布或调试中,项目运行没有任何问题。但是,如果我尝试添加断点(当然是在调试中)并单步执行代码,我很快就会收到以下随机错误:
下级停止了,因为它收到了来自操作系统的信号。
信号名称: 信号发生器 信号含义: 分段错误
QtCreator 此时显示一些小的汇编代码:
Dump of assembler code for function __nptl_death_event:
0x00e80d00 <+0>: push %ebp
0x00e80d01 <+1>: mov %esp,%ebp
0x00e80d03 <+3>: pop %ebp
0x00e80d04 <+4>: ret
End of assembler dump.
我正在运行:
Qt Creator 2.1.0 基于 Qt 4.7.2(32 位) 在 Mac 上通过 VMWare 在 Ubuntu 11.04 上运行。
我不知道 VMWare 是否会成为潜在的问题根源。我怀疑我在调试时也可能做错了什么,因为我不理解外部/附加术语(我还没有时间对此进行一些研究,同时发现很多东西,有点不知所措...)
感谢您的帮助。
I am new to Linux, Qt, and relatively junior in C++; so the problem I experience is very likely to be my own fault... Any help is very much appreciated.
I encounter a Segmentation Fault when trying to go step by step in basically any project. For instance, the tablemodel project included in QtCreator. In release or in debug, the projects runs without any problem. But if I try adding breakpoints (in debug of course) and stepping through the code, I quickly get the following random error:
The inferior stopped because it received a signal from the Operating System.
Signal name :
SIGSEGV
Signal meaning :
Segmentation fault
QtCreator at that point shows some small assembly code:
Dump of assembler code for function __nptl_death_event:
0x00e80d00 <+0>: push %ebp
0x00e80d01 <+1>: mov %esp,%ebp
0x00e80d03 <+3>: pop %ebp
0x00e80d04 <+4>: ret
End of assembler dump.
I am running :
Qt Creator 2.1.0 Based on Qt 4.7.2 (32 bit)
on Ubuntu 11.04 via VMWare on a Mac.
I don't know if VMWare can be a potential source of problem. I suspect I might also be doing something wrong when debugging because I don't understand the external / attach terms ( I haven't had the time to do some research on that yet, so many things to discover at the sametime, a bit overwhelming...)
Thanks for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信这是您的 GDB 副本的问题 - 更具体地说,是模块或库不匹配。
尝试重新编译 GDB,以便您知道它可以与本地 glibc 和 pthreads 库一起使用。
附带说明一下,该汇编代码是一个空函数。它设置一个堆栈帧,再次将其撕下来,然后返回。它似乎使用 cdecl 调用约定,这意味着它编写的库是 C (而不是 C++ )
I believe this is a problem with you copy of GDB - more specifically, a module or library mismatch.
Try recompiling GDB so that you know it will work with your local glibc and pthreads libraries.
As a side note, that assembly code is an empty function. It sets up a stack frame, tears it right back down again, and returns. It appears to use the cdecl calling convention, which implies the library it was written in is C (rather than C++ )