qtcreator crashes stopping the application
-
i run under debugger - no crashes in my app
but gdb not enters in my signal handler too - maybe creator(gdb) intercepted it
then i try to kill myapp outside from console - creator saw it, then show popup window about signal and then i continued - app exits with no error
-
i run under debugger - no crashes in my app
but gdb not enters in my signal handler too - maybe creator(gdb) intercepted it
then i try to kill myapp outside from console - creator saw it, then show popup window about signal and then i continued - app exits with no error
@abarmotov
Try putting a breakpoint on the signal handler function.
IIRC the signal first goes to gdb, then you have to continue for it to be delivered to program.
The point to discover is whether your signal handler ever gets hit at all --- even anfprintf(stderr)
orqDebug()
as first statement in handler might tell you. -
@abarmotov
Need to determine if @J-Hilk'sIIRC Creator sends SIGTERM and/or SIGKILL to the application process when that button is pressed
is right. Like I just wrote, put some
fprintf(stderr)
orqDebug()
as first statement in handler.BTW, do you want to show what code you actually do have in your signal handler(s)?
-
- where is printf in handler
- i will show code little latter, and attach to bugreport - there is no secret, but i need to remove excess code
@abarmotov said in qtcreator crashes stopping the application:
where is printf in handler
What do you mean by this? Unless you are ignoring the signals you have specified a function to be executed when the signals arrive. That is a "handler" function. You have some code in that function? I am suggesting you might put a
fprintf(stderr, "Caught signal!\n")
orqDebug() << "Caught signal!"
as the first statement in whatever you have, so that we might see whether it is ever hit (in case breakpoints aren't working right). -
- create new app in creator
- add some little code "signalhandler"
- run it Ctrl-R
4.1 kill from creator
4.2 kill from outside konsoles
#include "mainwindow.h" #include <QApplication> #include <unistd.h> #include <signal.h> void signalhandler(int sig) { printf("SIG = %i\n", sig); int ExitHelperCode = 0; if (sig == SIGINT || sig == SIGTERM) ExitHelperCode = 123; else if (sig == SIGUSR1) ExitHelperCode = 124; qApp->exit(ExitHelperCode); } int main(int argc, char *argv[]) { signal(SIGINT, signalhandler); signal(SIGTERM, signalhandler); QApplication a(argc, argv); MainWindow w; w.show(); return a.exec(); }
-
- create new app in creator
- add some little code "signalhandler"
- run it Ctrl-R
4.1 kill from creator
4.2 kill from outside konsoles
#include "mainwindow.h" #include <QApplication> #include <unistd.h> #include <signal.h> void signalhandler(int sig) { printf("SIG = %i\n", sig); int ExitHelperCode = 0; if (sig == SIGINT || sig == SIGTERM) ExitHelperCode = 123; else if (sig == SIGUSR1) ExitHelperCode = 124; qApp->exit(ExitHelperCode); } int main(int argc, char *argv[]) { signal(SIGINT, signalhandler); signal(SIGTERM, signalhandler); QApplication a(argc, argv); MainWindow w; w.show(); return a.exec(); }
-
Did you ever get to see the output from the
printf("SIG = %i\n", sig);
which is there? -
Comment out the
qApp->exit(ExitHelperCode);
. Does that have any effect on the "crash" you report? And btw how do you know your app was "crashing", given that it was supposed to exit?
It all still boils down to whether that signal handler function is being hit at all when you press the "Stop" button from Creator.
You might also try
signal(SIGINT, SIG_IGN); signal(SIGTERM, SIG_IGN);
instead as your first two lines in
main()
. -
- yes , i saw "SIG = 15", then kill app from from console
- myapp was "crashing" - that qtcreator says in output window
@abarmotov
Yes, that'sSIGTERM
. I think you are saying it hit yourprintf("SIG = %i\n", sig);
line, so we know it went intosighandler()
? Then like I said try commenting out theqApp->exit(ExitHelperCode);
, it may not be possible/safe to call that from within a signal handler. -
- yes , i saw "SIG = 15", then kill app from from console
- myapp was "crashing" - that qtcreator says in output window
When trying to stop the application, the result is set to QProcess::CrashExit temporarily and updated whenever your process comes back with a proper exit. Your process doesn't come back with something better, so you get the "%1 crashed" response.
I don't really see this as a bug, at best the exit code should perhaps be part of the message.
-
hm, if qApp->exit(ExitHelperCode) is not the safe - that it should to be ?
that code works fine before qtcreator v.7 and works fine in my app as ubuntu service@abarmotov
That is not the current question. The question is: does the crash, misbehaviour or whatever the issue is go away if you remove that line? By now you could have given us that answer :) -
@abarmotov said in qtcreator crashes stopping the application:
if i remove qApp->exit, then:
- SIG = 15 and SIG = 2 printed IF i send that signals from console (or from kde task manager), but app continue working
- from creator "red" button crash my app still
i will try to check this behavior on another machine from new user with clean configs ...
-
fresh install on new user - same behavior
so need to know which signal creator sends to app on press "red" button - KILL, TERM, INT ...@abarmotov
I would suggest likelySIGTERM
under Linux, as per https://stackoverflow.com/questions/14137808/signals-sent-by-qtcreator-on-stop from 10 years ago....UPDATE
I was going to try your issue. Very unfortunately/scarily, the VirtualBox VM I use for Ubuntu has encountered a "critical error" while it was applying the latest Ubuntu patches (which I always do when firing up), and now will not get me into Ubuntu at all, and I don't know what to do. This has never happened before, and seems to leave me with an unrecoverable box :@ I am not a happy bunny.... Will get back to you if/when I can resolve this.... -
@abarmotov
Well most all signal handling is done by gdb, not Creator. What "crashes" when you do what? I certainly haveSIGINT
handling in my application and works fine under gdb/Creator. (Though I admit I do not use Creator 7.x, and wouldn't use any of the latest stuff.) Have you tried disabling your program's signal handling temporarily to see if the "crashing" goes away?There should be a "debugger log window".: Window > Views > Debugger Log. This shows communicatins between Creator and gdb. That might tell you what communications happened that you are interested in.
Interesting blog in https://myprogrammingnotes.com/qt-creator-interact-debugger-gdb.html.
Code at https://github.com/qt-creator/qt-creator/blob/master/src/plugins/debugger/gdb/gdbengine.cpp. If you asked me to guess I'd hazard GdbEngine::interruptInferior()
No sign of any Linux
signal
s being used to gdb. If you find otherwise let me know! :) -
fresh install on new user - same behavior
so need to know which signal creator sends to app on press "red" button - KILL, TERM, INT ...@abarmotov
I have now recovered my Ubuntu VM successfully --- phew! :)I have pasted exactly your program. Run from Creator, press red Stop button. All is well, no crash. Application Output window:
13:48:42: Starting /home/jon/QtTests/build-signals-Desktop-Debug/signals ... SIG = 15 13:48:48: /home/jon/QtTests/build-signals-Desktop-Debug/signals exited with code 123
As you can see it received a
SIGTERM
, it was handled and it exited cleanly.Purely OOI, if run under Debug and click red Stop button program exits completely, cleanly, no crash, but does not visit the signal handler function. In this case the debugger is handling the Stop and doing whatever it does to stop its inferior process (the program being debugged) without sending it the
SIGTERM
signal.I am Ubuntu 20.04, Qt 5.12.5 (as supplied with Ubuntu) and Qt Creator 4.11.0. I therefore conclude that this is a Creator 7.x issue. Which does not surprise me....
-
@abarmotov
I have now recovered my Ubuntu VM successfully --- phew! :)I have pasted exactly your program. Run from Creator, press red Stop button. All is well, no crash. Application Output window:
13:48:42: Starting /home/jon/QtTests/build-signals-Desktop-Debug/signals ... SIG = 15 13:48:48: /home/jon/QtTests/build-signals-Desktop-Debug/signals exited with code 123
As you can see it received a
SIGTERM
, it was handled and it exited cleanly.Purely OOI, if run under Debug and click red Stop button program exits completely, cleanly, no crash, but does not visit the signal handler function. In this case the debugger is handling the Stop and doing whatever it does to stop its inferior process (the program being debugged) without sending it the
SIGTERM
signal.I am Ubuntu 20.04, Qt 5.12.5 (as supplied with Ubuntu) and Qt Creator 4.11.0. I therefore conclude that this is a Creator 7.x issue. Which does not surprise me....