From ac59cc7e007a3ef73a07f3d31d4a9516fd5f56f5 Mon Sep 17 00:00:00 2001 From: "Martin T. H. Sandsmark" Date: Sat, 3 Jun 2017 19:53:49 +0200 Subject: [PATCH] Fix hang on a lot of output from a program Summary: There is a bug in the Qt glib event loop leading to timers never being able to deliver signals. Work around this by disabling the glib event loop. References: http://lists.qt-project.org/pipermail/interest/2015-September/018846.html https://bugreports.qt.io/browse/QTBUG-48344 Test plan: From the referenced bug: Stefan Westerfeld 2010-03-10 11:40:24 UTC Running the following program within konsole: #include int main() { for (int i = 0; i < 100000000; i++) { fprintf (stderr, "foo %d\n", i); } } leads to a freeze - not single message is printed - no reaction on return. Only after a long time (30 seconds) something happens. If I run the same program in an xterm, the messages are scrolling through, as I would expect from that kind of output. Reviewers: #konsole, hindenburg Reviewed By: #konsole, hindenburg Subscribers: hindenburg Tags: #konsole Differential Revision: https://phabricator.kde.org/D6078 BUG: 230184 --- src/main.cpp | 8 ++++++++ tests/spam-stderr.c | 15 +++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 tests/spam-stderr.c diff --git a/src/main.cpp b/src/main.cpp index 81cbba1c..3ce429f9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -75,6 +75,14 @@ extern "C" int Q_DECL_EXPORT kdemain(int argc, char *argv[]) needToDeleteQApplication = true; } +#if defined(Q_OS_LINUX) + // Workaround for https://bugreports.qt.io/browse/QTBUG-48344 + // See also https://bugs.kde.org/show_bug.cgi?id=230184 + // The Qt glib event loop doesn't let timers deliver events if there are a + // lot of other events. + qputenv("QT_NO_GLIB", "1"); +#endif + auto app = new QApplication(argc, argv); // enable high dpi support diff --git a/tests/spam-stderr.c b/tests/spam-stderr.c new file mode 100644 index 00000000..e6f1c2c8 --- /dev/null +++ b/tests/spam-stderr.c @@ -0,0 +1,15 @@ +// from https://bugs.kde.org/show_bug.cgi?id=230184 +// author Stefan Westerfeld + +#include + +int +main() +{ + for (int i = 0; i < 100000000; i++) + { + fprintf (stderr, "foo %d\n", i); + } +} + +