summaryrefslogtreecommitdiffstats
path: root/meta-agl-core/recipes-graphics/wayland/weston/0003-libweston-desktop-add-weston_desktop_xwayland_fini.patch
diff options
context:
space:
mode:
authorduerpei <duep.fnst@fujitsu.com>2022-03-14 13:27:43 +0800
committerJan-Simon Moeller <jsmoeller@linuxfoundation.org>2022-03-18 10:17:05 +0000
commit4c2a3dbe7b652e679c9228d7d8c81aa641bd968b (patch)
tree14f974ce012b6e76c5680ed624633e5d2d9b9ac1 /meta-agl-core/recipes-graphics/wayland/weston/0003-libweston-desktop-add-weston_desktop_xwayland_fini.patch
parent7d671af1dc9bc1d1e70a113a2e4a84e63a141814 (diff)
Fix potential memory leak of two pointers (xwayland and client)
This backports four patches from weston to solve a memory leak problem These four patches are: https://gitlab.freedesktop.org/wayland/weston/-/commit/5a6604a7a2e52e5cd84c1f53724b3f7c325b5dff.patch https://gitlab.freedesktop.org/wayland/weston/-/commit/f53c05d3c2c19c139c52e9bd621c2654dd3dac69.patch https://gitlab.freedesktop.org/wayland/weston/-/commit/e2583ca0844bd7a8ce4fc94da9ad67edf49ffd45.patch https://gitlab.freedesktop.org/wayland/weston/-/commit/8740037a93c7c4400cc381ecf3009d1e4014be07.patch The following is the valgrind log: 160 bytes in 1 blocks are definitely lost in loss record 39 of 66 at 0x484B64C: calloc (in /usr/lib/valgrind/vgpreload_memcheck-arm64-linux.so) by 0x4A73C87: ??? (in /usr/lib/libweston-desktop-8.so.0.0.0) by 0x4A7184F: weston_desktop_create (in /usr/lib/libweston-desktop-8.so.0.0.0) by 0x487096B: ivi_desktop_init (in /usr/lib/agl-compositor/libexec_compositor.so.0.0.0) by 0x486F5E7: wet_main (in /usr/lib/agl-compositor/libexec_compositor.so.0.0.0) by 0x48B010F: (below main) (in /lib/libc-2.31.so) In agl-compositor/src/composiotr.c "ivi->desktop->compositor->xwayland" is zalloced by wet_main()->ivi_desktop_init()->weston_desktop_create()->weston_desktop_xwayland_init() "ivi->desktop->compositor->xwayland->client" is zalloced by wet_main()->ivi_desktop_init()->weston_desktop_create()->weston_desktop_xwayland_init()->weston_desktop_client_create() "ivi->desktop->compositor->xwayland" and "ivi->desktop->compositor->xwayland->client" The memory pointed to has not been released Now, I want to free the memory pointed by the two pointers. What can do this is the function of weston_desktop_xwayland_fini() in 0003-libweston-desktop-add-weston_desktop_xwayland_fini.patch And the submission of this patch depends on the first three patches, so I submitted these four patches. Bug-AGL: SPEC-4291 Signed-off-by: duerpei <duep.fnst@fujitsu.com> Change-Id: I3b1140e88eadad9e378c2bb43221026e280ecd90 Reviewed-on: https://gerrit.automotivelinux.org/gerrit/c/AGL/meta-agl/+/27257 Reviewed-by: Marius Vlad <marius.vlad@collabora.com> Reviewed-by: Jan-Simon Moeller <jsmoeller@linuxfoundation.org> Tested-by: Jenkins Job builder account
Diffstat (limited to 'meta-agl-core/recipes-graphics/wayland/weston/0003-libweston-desktop-add-weston_desktop_xwayland_fini.patch')
-rw-r--r--meta-agl-core/recipes-graphics/wayland/weston/0003-libweston-desktop-add-weston_desktop_xwayland_fini.patch99
1 files changed, 99 insertions, 0 deletions
diff --git a/meta-agl-core/recipes-graphics/wayland/weston/0003-libweston-desktop-add-weston_desktop_xwayland_fini.patch b/meta-agl-core/recipes-graphics/wayland/weston/0003-libweston-desktop-add-weston_desktop_xwayland_fini.patch
new file mode 100644
index 000000000..1bcf5c7b4
--- /dev/null
+++ b/meta-agl-core/recipes-graphics/wayland/weston/0003-libweston-desktop-add-weston_desktop_xwayland_fini.patch
@@ -0,0 +1,99 @@
+From e2583ca0844bd7a8ce4fc94da9ad67edf49ffd45 Mon Sep 17 00:00:00 2001
+From: Pekka Paalanen <pekka.paalanen@collabora.com>
+Upstream-Status: Backport
+Date: Fri, 14 May 2021 16:12:35 +0300
+Subject: [PATCH] libweston-desktop: add weston_desktop_xwayland_fini()
+
+This fixes the following leaks detected by ASan in
+./tests/test-alpha-blending:
+
+Direct leak of 176 byte(s) in 2 object(s) allocated from:
+ #0 0x7fb447880518 in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9518)
+ #1 0x7fb4432c12d7 in zalloc ../../git/weston/include/libweston/zalloc.h:38
+ #2 0x7fb4432c2ca6 in weston_desktop_xwayland_init ../../git/weston/libweston-desktop/xwayland.c:410
+ #3 0x7fb4432baadf in weston_desktop_create ../../git/weston/libweston-desktop/libweston-desktop.c:87
+ #4 0x7fb4432e1e1f in wet_shell_init ../../git/weston/tests/weston-test-desktop-shell.c:224
+ #5 0x7fb44775fddd in wet_load_shell ../../git/weston/compositor/main.c:956
+ #6 0x7fb447770db1 in wet_main ../../git/weston/compositor/main.c:3434
+ #7 0x56172c599279 in execute_compositor ../../git/weston/tests/weston-test-fixture-compositor.c:432
+ #8 0x56172c59cce5 in weston_test_harness_execute_as_client ../../git/weston/tests/weston-test-runner.c:528
+ #9 0x56172c58dc8c in fixture_setup ../../git/weston/tests/alpha-blending-test.c:65
+ #10 0x56172c58dd31 in fixture_setup_run_ ../../git/weston/tests/alpha-blending-test.c:67
+ #11 0x56172c59d29a in main ../../git/weston/tests/weston-test-runner.c:661
+ #12 0x7fb4473d509a in __libc_start_main ../csu/libc-start.c:308
+
+Indirect leak of 144 byte(s) in 2 object(s) allocated from:
+ #0 0x7fb447880518 in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9518)
+ #1 0x7fb4432bb592 in zalloc ../../git/weston/include/libweston/zalloc.h:38
+ #2 0x7fb4432bb882 in weston_desktop_client_create ../../git/weston/libweston-desktop/client.c:108
+ #3 0x7fb4432c2d0e in weston_desktop_xwayland_init ../../git/weston/libweston-desktop/xwayland.c:415
+ #4 0x7fb4432baadf in weston_desktop_create ../../git/weston/libweston-desktop/libweston-desktop.c:87
+ #5 0x7fb4432e1e1f in wet_shell_init ../../git/weston/tests/weston-test-desktop-shell.c:224
+ #6 0x7fb44775fddd in wet_load_shell ../../git/weston/compositor/main.c:956
+ #7 0x7fb447770db1 in wet_main ../../git/weston/compositor/main.c:3434
+ #8 0x56172c599279 in execute_compositor ../../git/weston/tests/weston-test-fixture-compositor.c:432
+ #9 0x56172c59cce5 in weston_test_harness_execute_as_client ../../git/weston/tests/weston-test-runner.c:528
+ #10 0x56172c58dc8c in fixture_setup ../../git/weston/tests/alpha-blending-test.c:65
+ #11 0x56172c58dd31 in fixture_setup_run_ ../../git/weston/tests/alpha-blending-test.c:67
+ #12 0x56172c59d29a in main ../../git/weston/tests/weston-test-runner.c:661
+ #13 0x7fb4473d509a in __libc_start_main ../csu/libc-start.c:308
+
+Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
+---
+ libweston-desktop/internal.h | 2 ++
+ libweston-desktop/libweston-desktop.c | 2 ++
+ libweston-desktop/xwayland.c | 16 ++++++++++++++++
+ 3 files changed, 20 insertions(+)
+
+diff --git a/libweston-desktop/internal.h b/libweston-desktop/internal.h
+index 7a815bd87..2606d279b 100644
+--- a/libweston-desktop/internal.h
++++ b/libweston-desktop/internal.h
+@@ -240,5 +240,7 @@ weston_desktop_wl_shell_create(struct weston_desktop *desktop,
+
+ void
+ weston_desktop_xwayland_init(struct weston_desktop *desktop);
++void
++weston_desktop_xwayland_fini(struct weston_desktop *desktop);
+
+ #endif /* WESTON_DESKTOP_INTERNAL_H */
+diff --git a/libweston-desktop/libweston-desktop.c b/libweston-desktop/libweston-desktop.c
+index c1efd2012..2b42ac7e3 100644
+--- a/libweston-desktop/libweston-desktop.c
++++ b/libweston-desktop/libweston-desktop.c
+@@ -95,6 +95,8 @@ weston_desktop_destroy(struct weston_desktop *desktop)
+ if (desktop == NULL)
+ return;
+
++ weston_desktop_xwayland_fini(desktop);
++
+ if (desktop->wl_shell != NULL)
+ wl_global_destroy(desktop->wl_shell);
+ if (desktop->xdg_shell_v6 != NULL)
+diff --git a/libweston-desktop/xwayland.c b/libweston-desktop/xwayland.c
+index 711c8a30c..c1c5fc4a7 100644
+--- a/libweston-desktop/xwayland.c
++++ b/libweston-desktop/xwayland.c
+@@ -423,3 +423,19 @@ weston_desktop_xwayland_init(struct weston_desktop *desktop)
+ compositor->xwayland = xwayland;
+ compositor->xwayland_interface = &weston_desktop_xwayland_interface;
+ }
++
++void
++weston_desktop_xwayland_fini(struct weston_desktop *desktop)
++{
++ struct weston_compositor *compositor = weston_desktop_get_compositor(desktop);
++ struct weston_desktop_xwayland *xwayland;
++
++ xwayland = compositor->xwayland;
++
++ weston_desktop_client_destroy(xwayland->client);
++ weston_layer_fini(&xwayland->layer);
++ free(xwayland);
++
++ compositor->xwayland = NULL;
++ compositor->xwayland_interface = NULL;
++}
+--
+GitLab
+