什么是 SIGSEGV,Qt 中的分段错误
我有一个 Qt 程序,它显示通过 UDP 接收的数据。 它在大约 30 秒内工作正常,但一段时间后就会出现分段错误并崩溃。这30秒也不是固定的。
我使用调试器并得到以下信息:
Program received signal SIGSEGV, Segmentation fault.
0x003c6fd4 in ?? () from /usr/lib/libQtGui.so.4
谁能告诉我错误可能出在哪里?
I have a Qt program which displays the data it receives over UDP.
It works fine for around 30 seconds but after a while it gives Segmentation Fault and crashes. This 30 seconds is also not fixed.
I used the debugger and got this:
Program received signal SIGSEGV, Segmentation fault.
0x003c6fd4 in ?? () from /usr/lib/libQtGui.so.4
Can anyone tell me where the error might be?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这意味着您的程序试图访问不属于它的内存。基本上,您的代码中某处有一个包含无效值的指针 - 此错误的常见来源是取消引用 NULL 指针。
It means your program has tried to access memory that doesn't belong to it. Basically, you have a pointer that contains an invalid value somewhere in your code - a common source of this error is dereferencing a NULL pointer.
您需要一个调试器(并确保您有带有调试信息的二进制文件)——检查崩溃站点的堆栈跟踪。我几乎假设您自己的代码会出现在某个地方,这就是开始的要点。检查分配、缓冲区大小……
You need a debugger (and make sure you have binaries with debug information) -- check the stack trace at the crash site. I'd pretty much assume your own code will appear somewhere, and this is the point to start with. Check allocations, buffer sizes …
确保您已分配要为其分配数据的数组。
我经常因为没有分配而出现这个错误。
我使用的示例:
后者更改为,并且有效:
祝你好运! :)
Make sure you have allocated array that you are assigning data to.
I have constantly had this error for not allocating.
Example I have used:
Latter changed to, and it worked:
Best of luck! :)