开发者

Whats SIGSEGV, Segmentation fault in Qt

开发者 https://www.devze.com 2022-12-22 21:44 出处:网络
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 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?


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:

char* m_tempBuff;
*(int*) m_tempBuff = i;

Latter changed to, and it worked:

char m_tempBuff[sizeof(int)];
*(int*) m_tempBuff = i;

Best of luck! :)

0

精彩评论

暂无评论...
验证码 换一张
取 消