Very simple question but I can't find any solution on the net.
Is it possible to force a Qt app to crash?
This is only for development purposes as I'd like to experiment with the crash report.
Very simple question but I can't find any solution on the net.
Is it possible to force a Qt app to crash?
This is only for development purposes as I'd like to experiment with the crash report.
Remember, we're on StackOverflow :-)
How about:
int foo(int p) {
return foo(p)+foo(p);
}
foo(0);
PS for something tamer and more Qt-specific, you can experiment with qFatal:
qFatal("boom");
You could throw an exception and never catch it, this may or may not be what you are looking for.
Edit:
this is the cross-platform most robust solution i could find: http://en.cppreference.com/w/cpp/utility/program/raise
If you are using *nix systems, you can use the raise call.
I assume you are already platform specific as you are making a crash report, which i know of no way to make cross platform at the moment. I don't know about a similar solution that would work in a windows environment, one probably exists.
You can trigger a segfault using the signal Linux library:
#include <signal.h>
void raiseSegfault()
{
int error = raise(SIGSEGV);
if (error != 0) {
std::cout << "cannot raise segfault" << std::endl;
exit(0);
}
}
This will reliably raise a segmentation fault or exit and will not rely on undefined behaviour.