2 Attachment(s)
weird segmentation fault on startup
Hi there,
I'm currently experiencing a strange behaviour.
Code:
DEFINES += QT_NO_DEBUG_OUTPUT
CONFIG += release
TARGET = myProg
TEMPLATE = app
When built as realease it leads to a segmentation error on startup insight the IDE.
I switch to debug mode using modified pro file
Code:
#DEFINES += QT_NO_DEBUG_OUTPUT
#CONFIG += release
TARGET = myProg
TEMPLATE = app
It runs fine.
Attachment 13602
When it occurs, it compiles and starts. On startup it runs into the error. The strange thing now is: I can press the "resume"-button, and it works. Program starts after hitting this button twice. Furthermore I can deploy the resulting *.exe and it works without any problems.
However I'm not a pro-programmer. I'm more or less coming from the "user"-side and I used Qt as a substitute for Matlab. That's why I'm not to familiar with debugging methods. I debugged algorithms and functions, observed incrementors and condition. But this seems to be beyond my horizon. Looks like it involves system-functions and -libraries. I would be glad if somebody could give me a hint on how to start finding out all about this.
I did an update to latest Qt5-version. No effect.
Attachment 13603
Thanks in advance, Lars
Re: weird segmentation fault on startup
A lot of times you will see errors like this where the program runs fine in the debugger but crashes in release mode, and it is generally due to an uninitialized variable or a variable that is out of range (like an index or a pointer). In debug mode, the debugger usually sets all variable values to a known but illegal value (like 0xdcdcdcdc for pointers) so when your program crashes in the debugger you can immediately see the problem when you inspect the variables.
This doesn't happen in release mode. Uninitialized variables have whatever random value the memory contains when the program starts. Sometimes the program runs OK but produces weird results because an index has a random but valid value. Other times it simply crashes.
So I would start by checking for that. If you raise the "complaint" level for your compiler output, it will tell you about uninitialized variables, and if you set the complaint level high enough it will turn those warnings into errors so you can't ignore them.
Quote:
Furthermore I can deploy the resulting *.exe and it works without any problems.
Might be just luck, or it might be a difference in the libraries on your development system vs. the deployment system. "Dependency Walker" (depends.exe) might help you determine if there are any significant differences between the libraries pulled in at runtime on your system vs. the other.
Re: weird segmentation fault on startup
Hey d_stranz,
thanks so much for that reply. What puzzled me is that I run the deployed *.exe on the very same machine without any problem.
I'm afraid it is actually going deeper. I figured out that since I updated VMWare-Horizon-Agent on this machine I got this error.
I'll try to rollback and see.
But to come back to your advice (helpfull as always): how would I raise the "complainement factor" of my compiler? Sounds interesting, never done this.
Regards, Lars
Re: weird segmentation fault on startup
Quote:
how would I raise the "complainement factor" of my compiler?
What compiler are you using?
For Microsoft Visual C++, you add "/W4" for the highest level of warnings, and "/WX" to treat warnings as errors.
For MinGW/gcc, "-Wall" is the highest level, and "-Werror" turns warnings into errors.
These are added to the command-line specification for the compiler. In Visual Studio, you add it on the "C/C++ -> General" section of the project's Property Pages dialog. I don't use Qt Creator so I don't know where to put it on that.
Re: weird segmentation fault on startup
Thanks. In this case I use mingw32. I think in creators project setting page you can specify commandline option. I'll try and come back.
Cheers.