Filter zero frames from the end of the stack returned by libunwind
authorMilian Wolff <milian.wolff@kdab.com>
Wed, 3 May 2017 15:35:18 +0000 (17:35 +0200)
committerMilian Wolff <milian.wolff@kdab.com>
Wed, 3 May 2017 15:36:41 +0000 (17:36 +0200)
Some (older) versions of libunwind eratically return zero frames
at the end of the stack. This happened on Debian and Ubuntu with the
distro provided libunwind. In such situations, we now skip these
uninteresting frames.

BUG: 379082

src/track/trace.h

index e986f29..3e96ff2 100644 (file)
@@ -59,6 +59,11 @@ struct Trace
     bool fill(int skip)
     {
         int size = unw_backtrace(m_data, MAX_SIZE);
+        // filter bogus frames at the end, which sometimes get returned by libunwind
+        // cf.: https://bugs.kde.org/show_bug.cgi?id=379082
+        while (size > 0 && !m_data[size - 1]) {
+            --size;
+        }
         m_size = size > skip ? size - skip : 0;
         m_skip = skip;
         return m_size > 0;