From e342a2e05f1e73c1a5cc4d029f9316401d07f3d6 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Thu, 11 Feb 2016 10:37:10 -0800 Subject: Add auto-test for crash in QCocoaBackingStore This issue has been solved some time between 5.6 and 5.6.0. We just make sure to protect against further regressions. Change-Id: Ic3fdad901ed5f36792ae04b3d65047da95eea668 Task-number: QTBUG-50561 Reviewed-by: Friedemann Kleint --- .../kernel/qwidget_window/tst_qwidget_window.cpp | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp index 58e85d6b58..27be063333 100644 --- a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp +++ b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp @@ -46,6 +46,8 @@ #include #include #include +#include +#include #include static inline void setFrameless(QWidget *w) @@ -99,6 +101,8 @@ private slots: void tst_move_count(); void tst_eventfilter_on_toplevel(); + + void QTBUG_50561_QCocoaBackingStore_paintDevice_crash(); }; void tst_QWidget_window::initTestCase() @@ -795,5 +799,46 @@ void tst_QWidget_window::tst_eventfilter_on_toplevel() QTRY_COMPARE(filter.eventCount, 1); } +class ApplicationStateSaver +{ +public: + ApplicationStateSaver() + { + QApplication::setAttribute(Qt::AA_NativeWindows, true); + QApplication::setQuitOnLastWindowClosed(false); + } + + ~ApplicationStateSaver() + { + QApplication::setAttribute(Qt::AA_NativeWindows, false); + QApplication::setQuitOnLastWindowClosed(true); + } +}; + +void tst_QWidget_window::QTBUG_50561_QCocoaBackingStore_paintDevice_crash() +{ + // Keep application state clean if testcase fails + ApplicationStateSaver as; + + QMainWindow w; + w.addToolBar(new QToolBar(&w)); + w.show(); + QTest::qWaitForWindowExposed(&w); + + // Simulate window system close + QCloseEvent *e = new QCloseEvent; + e->accept(); + qApp->postEvent(w.windowHandle(), e); + qApp->processEvents(); + + // Show again + w.show(); + qApp->processEvents(); + + // No crash, all good. + // Wrap up and leave + w.close(); +} + QTEST_MAIN(tst_QWidget_window) #include "tst_qwidget_window.moc" -- cgit v1.2.3 From 005a8bfbf0022f03dafafcf2b5c438ccf0675a49 Mon Sep 17 00:00:00 2001 From: James McDonnell Date: Fri, 18 Mar 2016 12:53:12 -0400 Subject: Remove QPROCESS_USE_SPAWN and all that it surrounds The spawn code was only used to make QProcess work on QNX 6.5.0. Fork works on QNX 6.6.0. The QNX spawn implementation has a flaw that causes a deadlock in certain situations. When a working directory is specified for the process, the QNX spawn implementation stops all threads except the one doing the spawn so that it can temporarily change the process' working directory. This can lead to a deadlock if the thread does anything that conficts with something being done in a stopped thread. QNX 6.5.0 is no longer supported in Qt 5.6.0 so we can just switch QNX to the fork implementation and get rid of the spawn implementation. Made a QNX specific adjustment to the hardExit test. There's a bug in the OS that the test can run into because it does something that normal applications wouldn't. Task-number: QTBUG-47250 Change-Id: Ib32567d2c15ce651815858000035ac5aa6f35224 Reviewed-by: Dan Cape Reviewed-by: Oswald Buddenhagen Reviewed-by: Rafael Roquetto --- tests/auto/corelib/io/qprocess/tst_qprocess.cpp | 38 +++++++------------------ 1 file changed, 10 insertions(+), 28 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index 46bf1a19e8..7e1d5487ba 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -45,8 +45,6 @@ #include #include -# include // only so we get QPROCESS_USE_SPAWN - typedef void (QProcess::*QProcessFinishedSignal1)(int); typedef void (QProcess::*QProcessFinishedSignal2)(int, QProcess::ExitStatus); typedef void (QProcess::*QProcessErrorSignal)(QProcess::ProcessError); @@ -325,9 +323,6 @@ void tst_QProcess::startDetached() { QVERIFY(QProcess::startDetached("testProcessNormal/testProcessNormal", QStringList() << "arg1" << "arg2")); -#ifdef QPROCESS_USE_SPAWN - QEXPECT_FAIL("", "QProcess cannot detect failure to start when using posix_spawn()", Continue); -#endif QCOMPARE(QProcess::startDetached("nonexistingexe"), false); } @@ -707,9 +702,6 @@ void tst_QProcess::waitForFinished() QCOMPARE(output.count("\n"), 10*1024); process.start("blurdybloop"); -#if defined(QPROCESS_USE_SPAWN) && !defined(Q_OS_QNX) - QEXPECT_FAIL("", "QProcess cannot detect failure to start when using posix_spawn()", Abort); -#endif QVERIFY(!process.waitForFinished()); QCOMPARE(process.error(), QProcess::FailedToStart); } @@ -922,6 +914,16 @@ void tst_QProcess::hardExit() #endif QVERIFY2(proc.waitForStarted(), qPrintable(proc.errorString())); + +#if defined(Q_OS_QNX) + // QNX may lose the kill if it's delivered while the forked process + // is doing the exec that morphs it into testProcessEcho. It's very + // unlikely that a normal application would do such a thing. Make + // sure the test doesn't accidentally try to do it. + proc.write("A"); + QVERIFY(proc.waitForReadyRead(5000)); +#endif + proc.kill(); QVERIFY(proc.waitForFinished(5000)); @@ -1503,11 +1505,6 @@ void tst_QProcess::nativeArguments() void tst_QProcess::exitCodeTest() { for (int i = 0; i < 255; ++i) { -#ifdef QPROCESS_USE_SPAWN - // POSIX reserves exit code 127 when using posix_spawn - if (i == 127) - continue; -#endif QProcess process; process.start("testExitCodes/testExitCodes " + QString::number(i)); QVERIFY(process.waitForFinished(5000)); @@ -1518,9 +1515,6 @@ void tst_QProcess::exitCodeTest() void tst_QProcess::failToStart() { -#if defined(QPROCESS_USE_SPAWN) && !defined(Q_OS_QNX) - QSKIP("QProcess cannot detect failure to start when using posix_spawn()"); -#endif qRegisterMetaType("QProcess::ProcessError"); qRegisterMetaType("QProcess::ExitStatus"); qRegisterMetaType("QProcess::ProcessState"); @@ -1591,9 +1585,6 @@ void tst_QProcess::failToStart() void tst_QProcess::failToStartWithWait() { -#if defined(QPROCESS_USE_SPAWN) && !defined(Q_OS_QNX) - QSKIP("QProcess cannot detect failure to start when using posix_spawn()"); -#endif qRegisterMetaType("QProcess::ProcessError"); qRegisterMetaType("QProcess::ExitStatus"); @@ -1623,9 +1614,6 @@ void tst_QProcess::failToStartWithWait() void tst_QProcess::failToStartWithEventLoop() { -#if defined(QPROCESS_USE_SPAWN) && !defined(Q_OS_QNX) - QSKIP("QProcess cannot detect failure to start when using posix_spawn()"); -#endif qRegisterMetaType("QProcess::ProcessError"); qRegisterMetaType("QProcess::ExitStatus"); @@ -1912,9 +1900,6 @@ void tst_QProcess::waitForReadyReadForNonexistantProcess() QVERIFY(!process.waitForReadyRead()); // used to crash process.start("doesntexist"); QVERIFY(!process.waitForReadyRead()); -#if defined(QPROCESS_USE_SPAWN) && !defined(Q_OS_QNX) - QEXPECT_FAIL("", "QProcess cannot detect failure to start when using posix_spawn()", Abort); -#endif QCOMPARE(errorSpy.count(), 1); QCOMPARE(errorSpy.at(0).at(0).toInt(), 0); QCOMPARE(errorSpy2.count(), 1); @@ -2282,9 +2267,6 @@ void tst_QProcess::setNonExistentWorkingDirectory() // while on Unix with fork it's relative to the child's (with posix_spawn, it could be either). process.start(QFileInfo("testSetWorkingDirectory/testSetWorkingDirectory").absoluteFilePath()); QVERIFY(!process.waitForFinished()); -#ifdef QPROCESS_USE_SPAWN - QEXPECT_FAIL("", "QProcess cannot detect failure to start when using posix_spawn()", Continue); -#endif QCOMPARE(int(process.error()), int(QProcess::FailedToStart)); } #endif -- cgit v1.2.3