Application does no longer start in Qt Creator once it has run into segfault in Linux
Just to add some background. I have been developing on Windows and now want to run on Linux to profile the application using Valgrind.
I have set up the project in Linux and it runs. Although as soon as i run into any segmentation faults. I get the following message:
"The program has unexpectedly finished"
.. exited with code 0
This is all good and expected.
Now when i remove the code that is causing the segmentation fault the program still builds without any errors but it will not run in Qt Creator anymore (it will run when manually executing in the terminal). Only way to get it running again normally (as far as i know), is to reboot the system.
Compile output:
12:46:46: Running build steps for project FrostBite...
12:46:46: Configuration unchanged, skipping qmake step.
12:46:46: Starting: "/usr/bin/make" -w
make: Entering directory `/home/matoom/projects/FrostBite-build-desktop-Qt_4_8_1_in_PATH__System__Debug'
cd data/ && /usr/bin/make -f Makefile
make[1]: Entering directory `/home/matoom/projects/FrostBite-build-desktop-Qt_4_8_1_in_PATH__System__Debug/data'
make[1]: Nothing to be done for `first'.
make[1]: Leaving directory `/home/matoom/projects/FrostBite-build-desktop-Qt_4_8_1_in_PATH__System__Debug/data'
cd gui/ && /usr/bin/make -f Makefile
make[1]: Entering directory `/home/matoom/projects/FrostBite-build-desktop-Qt_4_8_1_in_PATH__System__Debug/gui'
make[1]: Nothing to be done for `first'.
make[1]: Leaving directory `/home/matoom/projects/FrostBite-build-desktop-Qt_4_8_1_in_PATH__System__Debug/gui'
make: Leaving directory `/home/matoom/projects/FrostBite-build-desktop-Qt_4_8_1_in_PATH__System__Debug'
12:46:46: The process "/usr/bin/make" exited normally.
Application output:
Starting /home/matoom/projects/FrostBite-build-desktop-Qt_4_8_1_in_PATH__System__Debug/frostbite...
/home/matoom/projects/FrostBite-build-desktop-Qt_4_8_1_in_PATH__System__Debug/frostbite exited with code 0
Here are the project files that explain the structure in the compile output:
https://github.com/matoom/frostbite/...er/gui/gui.pro
https://github.com/matoom/frostbite/.../data/data.pro
https://github.com/matoom/frostbite/.../FrostBite.pro
--------
It seems to me that it tries to run and then exits right away but there is no indication to why.
My first thought was that it was crashing into Linux background somehow but this does not seem to be the case as i could not find anything in the process (ps) list.
Any help or hints for debugging this issue would be appreciated.
Thanks in advance,
Matoom
Re: Application does no longer start in Qt Creator once it has run into segfault in L
I figured out why this was happening and it wasn't related to qt creator but i can't find a way to delete this post.
Just for the odd chance someone runs into this issue. It was cause by using QSharedMemory to allow only single instance of application process to run. In Linux/Unix the shared memory did not get released after application crashed.
Code:
int main(int argc, char *argv[]) {
QSharedMemory shared
(QDir::currentPath());
if(!shared.create(512, QSharedMemory::ReadWrite)) {
Log4Qt
::Logger::logger(QLatin1String("ErrorLogger"))->info
("Application already running.");
exit(0);
}
...
}
Re: Application does no longer start in Qt Creator once it has run into segfault in L
Yes, on Unix shared memory is "owned" by the operating system itself: http://qt-project.org/doc/qt-4.8/qsh...y.html#details
An approach that should work better cross-platform is using a QLocalServer.
Has the additional benefit that you can use QLocalSocket in the second instance to communicate with the first one, e.g. passing command line arguments of the new invocation.
Cheers,
_