qtcreator crashes stopping the application
-
Which signal QtCreator sends to application then stopping it ?
Application has signal handlers on SIGINT and SIGTERM (and works well from console) but crashes from creator
QtCreator v.7.0.2, ubuntu 20.04@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! :) -
@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! :)@JonB thanks for answer
- application running without gdb - just "Run" with Ctrl+R
- then i stop app with "red button" - in console creator prints "... myapp crashed"
- as I remember, on version 6 it worked as it should - so it is a bug of v.7 or a new behavior ?
-
@JonB thanks for answer
- application running without gdb - just "Run" with Ctrl+R
- then i stop app with "red button" - in console creator prints "... myapp crashed"
- as I remember, on version 6 it worked as it should - so it is a bug of v.7 or a new behavior ?
@abarmotov said in qtcreator crashes stopping the application:
as I remember, on version 6 it worked as it should - so it is a bug of v.7 or a new behavior ?
Ah, well don't you think that says it all?!
Experts may slap me down, but from what I have seen (in posts) I wouldn't touch Creator 7 or Qt 6 with a barge-pole.
- Did you at least try removing your signal handlers?
- Would you consider "downgrading" to Creator 6? What do you get out of 7 that you need?
-
Please open a bug report at https://bugreports.qt.io/
Qt Creator crashing is always worth a bug report and ... it shouldn't happen. 😊
-
If I understand the op correctly, that QtCreator is not crashing, but his application is when he presses the "big" red stop button above the integrated terminal inside QtCreator.
That's not unexpected, IIRC Creator sends SIGTERM and/or SIGKILL to the application process when that button is pressed and thats not a clean exit for any program.
-
@JonB thanks for answer
- application running without gdb - just "Run" with Ctrl+R
- then i stop app with "red button" - in console creator prints "... myapp crashed"
- as I remember, on version 6 it worked as it should - so it is a bug of v.7 or a new behavior ?
@abarmotov said in qtcreator crashes stopping the application:
application running without gdb - just "Run" with Ctrl+R
Now that I understand you were never running under debugger, which I thought you were: have you indeed tried running it under debugger (Debug button)? If your code really is misbehaving in its signal handlers you may be able to debug that successfully.
-
@abarmotov said in qtcreator crashes stopping the application:
as I remember, on version 6 it worked as it should - so it is a bug of v.7 or a new behavior ?
Ah, well don't you think that says it all?!
Experts may slap me down, but from what I have seen (in posts) I wouldn't touch Creator 7 or Qt 6 with a barge-pole.
- Did you at least try removing your signal handlers?
- Would you consider "downgrading" to Creator 6? What do you get out of 7 that you need?
@JonB said in qtcreator crashes stopping the application:
Would you consider "downgrading" to Creator 6? What do you get out of 7 that you need?
- I noticed that v.7 is faster in clang code analysis, so not planned back to v.6
- qtcretor not crasing - but my app is
- I think that v.6 gave time to myapp to work out on the SIGTERM signal, but now it does not
- will make bugreport
-
@JonB said in qtcreator crashes stopping the application:
Would you consider "downgrading" to Creator 6? What do you get out of 7 that you need?
- I noticed that v.7 is faster in clang code analysis, so not planned back to v.6
- qtcretor not crasing - but my app is
- I think that v.6 gave time to myapp to work out on the SIGTERM signal, but now it does not
- will make bugreport
@abarmotov said in qtcreator crashes stopping the application:
I think that v.6 gave time to myapp to work out on the SIGTERM signal, but now it does not
Like I last wrote: have you at least tried Debug instead of Run to see what happens?
-
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.