PDA

View Full Version : SIGSEGV Error when debugging with Qt creator.



jiapei100
21st July 2012, 15:17
A related discuss can be found at
http://www.qtforum.org/article/31937/error-when-debugging-with-qt-creator.html#post119880


First of all, my environment:

Ubuntu 12.04
C++ gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)
Qt Creator 2.4.1 Based on Qt 4.8.0 (32 bit) Built on Mar 21 2012 at 23:05:03
Eclipse IDE for C/C++ Linux Developers Version: Indigo Service Release 2 Build id: 20120216-1857

I've got exactly the same problem now. I've got no idea why it is so.
I tried both Eclipse and QtCreator. Under Eclipse, my application runs fine, but under QtCreator, the application always meeting the SIGSEGV error:


The inferior stopped because it received a signal from the Operating System.

Signal name :
SIGSEGV
Signal meaning :
Segmentation fault


Why the same code passed one IDE, but failed the other????wired...


Cheers
Pei

amleto
21st July 2012, 22:43
guess I'll put my replies here as well then...


different compiler?


either way, it means that there is something wrong with you program - most likely it is something that is 'undefined behaviour', and you are just getting lucky with one compiler/ide

ChrisW67
22nd July 2012, 01:24
You claim both IDEs are using the same compiler so we can eliminate that as a cause. I assume both IDEs are using the same qmake, and therefore generating the same Makefile and linkages, so we can eliminate different compiler flags and libraries as a cause. I also assume that the run time environment is identical so the same libraries are picked up at run time. That leaves the most likely reasons for your program (yes, your code) failing:

You are using a an uninitialised, null, or deleted pointer. This might work some of the time but it will crash eventually.
You are holding and using a reference to an object that no longer exists: undefined behaviour

A few minutes running the compiled program in your debugger and inspecting the crash backtrace would have identified the problem far faster than posting the same thing in several forums.

jiapei100
22nd July 2012, 05:03
You are using a an uninitialised, null, or deleted pointer. This might work some of the time but it will crash eventually.
[LIST]

No. I didn't use any pointers. Particularly, for this variable and this piece of code. It's just an object of an OpenCV-defined class, has nothing to do with pointer.



[LIST]
You are holding and using a reference to an object that no longer exists: undefined behaviour


This might be the reason. But this is most probably caused by the difference between Eclipse and QtCreator. So, it seems you are 100% sure that QtCreator itself didn't do anything special here, right?



A few minutes running the compiled program in your debugger and inspecting the crash backtrace would have identified the problem far faster than posting the same thing in several forums.
How did you know I hadn't spent several minutes and tried to solve the problem? Clearly, if it's as easy as mentioned by you, I wouldn't have posted the messages on forums. ^_^

I seriously hope you can tell the difference between Qt Creator and Eclipse next time. Hope you really understand what's the difference between these two IDEs, the inner core, rather than just the superficial things.


Thanks

ChrisW67
22nd July 2012, 05:29
Edit: Removed terse response.


How did you know I hadn't spent several minutes and tried to solve the problem? Clearly, if it's as easy as mentioned by you, I wouldn't have posted the messages on forums.
How were we supposed to know that? You told us absolutely nothing about what you had done to find the issue in your code before your started blaming everything else.


I seriously hope you can tell the difference between Qt Creator and Eclipse next time. Hope you really understand what's the difference between these two IDEs, the inner core, rather than just the superficial things.
I do know the difference between these two dev environments. I also know that an IDE is a glorified text editor and plays no part in generating the actual executable binary: that's done by the compiler and linker in concert using your source. The "inner core" of your IDE, Java, C++, Haskell or pidgin English, has as much to do with code generation as my Aunt Fanny. That's also why I carefully stated my assumptions that you are using the same compiler and the same version of qmake from both IDEs: that eliminates the possibility of different compiler and linker command lines because under these circumstances the Makefile is identical regardless of the IDE.

I wish you luck finding the problem in your code.

amleto
22nd July 2012, 13:19
either way, it means that there is something wrong with you program - most likely it is something that is 'undefined behaviour', and you are just getting lucky with one compiler/ide

Hi, Amleto, Thank you very much for your prompt reply ! Thank you !!

However,
1) I don't think it has something to do with the compilers.
I built 11 libraries under Eclipse, and 7 applications under QtCreator, which are based on those 11 libraries. 6 out of these 7 applications work perfect under QtCreator, and there is only 1 doesn't work properly.

Since 6 are working. Thus, I don't think there is a problem with the compiler. In fact, both Eclipse and QtCreator are using the compiler GCC.

2) I don't think there are some problems with my code as well.
Because my code work fine under Codelite (this one supports qmake well) and Visual Studio 2010 (with Qt Integrator).

Conclusion: It could be a problem about the settings of compiler? I've no idea.


Anyway, thank you for your reply.


Best regards
Pei


Just because something works sometimes does not mean it is ok code according to the c++ standard. Therefore your supposition, above, is incorrect.

Compiler settings ... erm, it is still only going to compiler YOUR code. If your program goes wrong it's not the compiler's fault. Unless you are linking incorrect versions of libraries together (e.g. release + debug), 'settings' are not going to be the problem. We are back to YOUR code.

Can you see a common theme?


The problem is your code (99% probability).