From 47cb44c6eb39fa6eda3f8844c1e3e801e96d2cf6 Mon Sep 17 00:00:00 2001 From: Johannes Schlatow Date: Mon, 7 Feb 2022 15:57:52 +0100 Subject: [PATCH] os/trace_buffer.h: fix wraparound If the buffer contains padding at the end, the iteration must continue in order to restart iteration from the start of the buffer. genodelabs/genode#4244 --- repos/os/include/trace/trace_buffer.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/repos/os/include/trace/trace_buffer.h b/repos/os/include/trace/trace_buffer.h index 513fbed94c..cfc6dab8d8 100644 --- a/repos/os/include/trace/trace_buffer.h +++ b/repos/os/include/trace/trace_buffer.h @@ -79,8 +79,14 @@ class Trace_buffer if (wrapped && entry.last()) { wrapped = false; entry = _buffer.first(); - if (entry.last()) + if (entry.last()) { + new_curr = entry; break; + } + } + + if (!entry.length()) { + continue; } if (!functor(entry))