0

Consider the following code(The system specification is mentioned down below):

#include <stdexcept>
#include <thread>

void f()
{
  throw std::runtime_error("Something");
}
int main()
{
  std::thread thr(f);
  thr.join();
}

I easily could run it with a debugger and have the stack trace from where the exception threw. Like this: enter image description here

But the same code fails if I use a QThread instead of std::thread:

#include <QCoreApplication>
#include <QThread>

void f()
{
  throw std::runtime_error("Something");
}
int main(int argc, char* argv[])
{
  QCoreApplication app(argc, argv);

  auto const thr = QThread::create(f);
  thr->start();

  return QCoreApplication::exec();
}

Like this: enter image description here

It's possible to debug it like std::thread? and have the stack frames from where the exception threw?


Environment:

  • OS: Fedora 35
  • Kernel: Linux 5.15.10
  • Compiler: GCC 11.2.1
  • Qt: 5.15.2
  • QtCreator: 6.0.1
Ghasem Ramezani
  • 2,683
  • 1
  • 13
  • 32

0 Answers0