aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2023-11-14 21:30:36 +0200
committerTomi Valkeinen <tomi.valkeinen@ideasonboard.com>2023-11-15 08:52:57 +0200
commit9ae90ce75478e49844cf984562db0dc1a074462f (patch)
tree008ac36df12bcc75c1498796300cdef78860f55c
parentc23e7548ee317c043660f9b992388257e99f1776 (diff)
downloadlibkmsxx-upstream-master.tar.gz
testpat: Fix memory mapping in threaded drawingupstream-master
The IFramebuffer::map() function is not thread-safe, which is why the threaded implementation of draw_test_pattern_impl() maps all planes before starting to draw. A typo slipped in the code, resulting in only plane 0 being mapped. This didn't result in an immediate segfault, as drawing operations in the worker threads map the remaining planes. However, due to the implementation of DumbFramebuffer::map(), this can result in the same plane being mapped multiple times, with only one of the mapping recorded in the mapping cache. The other mappings are then leaked, leading not only to extra memory consumption, but also to the DRM device never being released even after the destruction of the Card object. Fix this. Fixes: 40d96062a37c ("Revert "testpat: remove threaded drawing"") Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
-rw-r--r--kms++util/src/testpat.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/kms++util/src/testpat.cpp b/kms++util/src/testpat.cpp
index 78c9d19..1102588 100644
--- a/kms++util/src/testpat.cpp
+++ b/kms++util/src/testpat.cpp
@@ -173,7 +173,7 @@ static void draw_test_pattern_impl(IFramebuffer& fb, YUVType yuvt)
// Create the mmaps before starting the threads
for (unsigned i = 0; i < fb.num_planes(); ++i)
- fb.map(0);
+ fb.map(i);
unsigned num_threads = thread::hardware_concurrency();
vector<thread> workers;