SylvainTI / ostinato

Automatically exported from code.google.com/p/ostinato
GNU General Public License v3.0
0 stars 0 forks source link

Endless Loop in drone, when compiled with disabled qDebug #146

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Add "DEFINES += QT_NO_DEBUG_OUTPUT" in all .pro files
2. Compile
3. Start drone
4. Push stream from GUI to drone (push apply on GUI)
5. drone gets unresponsive, CPU at 100%

What is the expected output? What do you see instead?
Expected is, that drone remains usable. Instead the drone hangs.

What version and revision of the product are you using (available in the
About dialog)? On what operating system?
V0.6 rev 2aaa068dcb55@, drone OS = Linux, GUI OS = Mac OS X

Please provide any additional information below.
The problem is, that QT_NO_DEBUG_OUTPUT replaces all qDebug calls by an empty 
macro. Therefore the arguments of qDebug are no longer evaluated. This is a 
problem, when using expressions with side effects.

I found 2 uses of iter->next arguments in qDebug calls in common/streambase.cpp 
. With QT_NO_DEBUG_OUTPUT these calls get optimized away, iter->next is never 
called. This leads to an endless loop.

Here my patch to fix it:

--- common/streambase.cpp.orig  2014-07-07 12:30:16.000000000 +0000
+++ common/streambase.cpp   2015-02-24 11:28:02.680482034 +0000
@@ -53,14 +53,16 @@
         iter->toFront();
         while (iter->hasNext())
         {
-            qDebug("{{%p}}", iter->next());
-        //    qDebug("{{%p}: %d}", iter->peekNext(), 
iter->next()->protocolNumber());
+            qDebug("{{%p}}", iter->peekNext());
+        //    qDebug("{{%p}: %d}", iter->peekNext(), 
iter->peekNext()->protocolNumber());
+            iter->next();
         }
         iter->toFront();
         while (iter->hasNext())
         {
-            qDebug("{[%d]}", iter->next()->protocolNumber());
-        //    qDebug("{{%p}: %d}", iter->peekNext(), 
iter->next()->protocolNumber());
+            qDebug("{[%d]}", iter->peekNext()->protocolNumber());
+        //    qDebug("{{%p}: %d}", iter->peekNext(), 
iter->peekNext()->protocolNumber());
+            iter->next();
         }
     }

Original issue reported on code.google.com by b...@bernhard-ehlers.de on 26 Feb 2015 at 5:54

GoogleCodeExporter commented 9 years ago
This issue was closed by revision f97120530881.

Original comment by pstav...@gmail.com on 27 Feb 2015 at 3:00

GoogleCodeExporter commented 9 years ago
@be: Thanks for the debug and patch. I've reworked the diff such that the code 
is not executed at all if QT_NO_DEBUG_OUTPUT is defined - the code was only for 
debug purposes.

Can you please try the updated code and confirm if it works?

Original comment by pstav...@gmail.com on 27 Feb 2015 at 3:03

GoogleCodeExporter commented 9 years ago
Thanks for reacting that fast.

Just tested the actual source (rev f97120530881), works perfect.

Original comment by b...@bernhard-ehlers.de on 27 Feb 2015 at 4:21