2

Is it possible to detect segmentation faults (SIGSEGV) within the Qt test library?

Within my testXXX() method, a segmentation fault is thrown which causes a core file to be written. The funny thing about that is that the QTest::qExec() method returns 0 from the method in question.

Even after the segmentation fault the Qt test framework keeps on running with the same PID!!!*

I've tried to set up a signal handler using the sigaction() system call, but that doesn't work either.

Any suggestions welcome and appreciated.

Santosh A
  • 5,173
  • 27
  • 37
mefiX
  • 1,702
  • 3
  • 24
  • 39
  • How do you know that you actually have SIGSEGV? – Pavel Strakhov Dec 12 '14 at 13:49
  • I can see it at the top of the stack trace in GDB. – mefiX Dec 15 '14 at 07:45
  • What do you mean by "does not work"? – László Papp Dec 16 '14 at 21:04
  • I found the underlying cause. Qt sets its own signal handler within `QTest::qExec()`, which will overwrite anything that has been set prior to that. I found that out while digging in `src/testlib/qtestcase.cpp`. There's a class `FatalSignalHandler` that will assign signal handlers for a bunch of signals in its constructor. – mefiX Dec 17 '14 at 09:33
  • Actually that is the answer, is it ok if I answer my own question? – mefiX Dec 17 '14 at 10:16

0 Answers0