From 823580e07094feab7d2a8a229fd7bd3a81dab5bc Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Wed, 12 Apr 2023 13:55:07 +0300 Subject: [PATCH] backend-headless: fully release pango and fontconfig In the color-icc-output test, this fixes the following ASan reports: Direct leak of 6912 byte(s) in 27 object(s) allocated from: #0 0x7f36bf0a9e8f in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145 #1 0x7f36bd9c2704 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x20704) #2 0x7f36bd9c2dc8 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x20dc8) #3 0x7f36bd9c439c (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2239c) #4 0x7f36bd9cb24c (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2924c) #5 0x7f36bd29c4a9 (/lib/x86_64-linux-gnu/libexpat.so.1+0xc4a9) #6 0x7f36bd29ada7 (/lib/x86_64-linux-gnu/libexpat.so.1+0xada7) #7 0x7f36bd29ba59 (/lib/x86_64-linux-gnu/libexpat.so.1+0xba59) #8 0x7f36bd29f8b0 in XML_ParseBuffer (/lib/x86_64-linux-gnu/libexpat.so.1+0xf8b0) #9 0x7f36bd9c9152 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x27152) #10 0x7f36bd9c956b (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2756b) #11 0x7f36bd9c977c (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2777c) #12 0x7f36bd9c9c9e (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x27c9e) #13 0x7f36bd29c4a9 (/lib/x86_64-linux-gnu/libexpat.so.1+0xc4a9) #14 0x7f36bd29ada7 (/lib/x86_64-linux-gnu/libexpat.so.1+0xada7) #15 0x7f36bd29ba59 (/lib/x86_64-linux-gnu/libexpat.so.1+0xba59) #16 0x7f36bd29f8b0 in XML_ParseBuffer (/lib/x86_64-linux-gnu/libexpat.so.1+0xf8b0) #17 0x7f36bd9c9152 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x27152) #18 0x7f36bd9c956b (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2756b) #19 0x7f36bd9bb507 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x19507) #20 0x7f36bd9bb766 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x19766) #21 0x7f36bd9ad926 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0xb926) #22 0x7f36bd9af8c6 in FcConfigSubstituteWithPat (/lib/x86_64-linux-gnu/libfontconfig.so.1+0xd8c6) #23 0x7f36ba21caae (/lib/x86_64-linux-gnu/libpangocairo-1.0.so.0+0xbaae) #24 0x7f36b9b8a6df (/lib/x86_64-linux-gnu/libpangoft2-1.0.so.0+0xc6df) #25 0x7f36b9b88bd9 (/lib/x86_64-linux-gnu/libpangoft2-1.0.so.0+0xabd9) #26 0x7f36b9db218d (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x2418d) #27 0x7f36b9db313b (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x2513b) #28 0x7f36b9db39aa (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x259aa) #29 0x7f36b9db84c8 (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x2a4c8) #30 0x7f36b9db8702 in pango_layout_get_pixel_extents (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x2a702) #31 0x7f36ba05fbb3 in theme_render_frame ../../git/weston/shared/cairo-util.c:586 #32 0x7f36ba06c7b7 in frame_repaint ../../git/weston/shared/frame.c:1071 #33 0x7f36ba07191b in weston_gl_borders_update ../../git/weston/libweston/gl-borders.c:81 #34 0x7f36ba0544c3 in headless_output_update_gl_border ../../git/weston/libweston/backend-headless/headless.c:150 #35 0x7f36ba0545a3 in headless_output_repaint ../../git/weston/libweston/backend-headless/headless.c:165 #36 0x7f36bea58238 in weston_output_repaint ../../git/weston/libweston/compositor.c:3115 #37 0x7f36bea5921d in weston_output_maybe_repaint ../../git/weston/libweston/compositor.c:3186 #38 0x7f36bea5a100 in output_repaint_timer_handler ../../git/weston/libweston/compositor.c:3267 #39 0x7f36beee6766 in wl_timer_heap_dispatch ../../git/wayland/src/event-loop.c:526 #40 0x7f36beee6766 in wl_event_loop_dispatch ../../git/wayland/src/event-loop.c:1020 #41 0x7f36beee41d4 in wl_display_run ../../git/wayland/src/wayland-server.c:1431 #42 0x7f36bfaa3dc3 in wet_main ../../git/weston/compositor/main.c:4080 #43 0x557d4f1e1703 in execute_compositor ../../git/weston/tests/weston-test-fixture-compositor.c:410 #44 0x557d4f1ebd43 in weston_test_harness_execute_as_client ../../git/weston/tests/weston-test-runner.c:534 #45 0x557d4f1c8568 in fixture_setup ../../git/weston/tests/color-icc-output-test.c:462 #46 0x557d4f1c861f in fixture_setup_run_ ../../git/weston/tests/color-icc-output-test.c:464 #47 0x557d4f1ec92e in main ../../git/weston/tests/weston-test-runner.c:682 #48 0x7f36bda4ed09 in __libc_start_main ../csu/libc-start.c:308 #49 0x557d4f1c5a89 in _start (/home/pq/build/weston-meson/tests/test-color-icc-output+0x3da89) Indirect leak of 1696 byte(s) in 53 object(s) allocated from: #0 0x7f36bf0aa037 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154 #1 0x7f36bd9c2d48 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x20d48) #2 0x7f36bd9c439c (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2239c) #3 0x7f36bd9cb24c (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2924c) #4 0x7f36bd29c4a9 (/lib/x86_64-linux-gnu/libexpat.so.1+0xc4a9) #5 0x7f36bd29ada7 (/lib/x86_64-linux-gnu/libexpat.so.1+0xada7) #6 0x7f36bd29ba59 (/lib/x86_64-linux-gnu/libexpat.so.1+0xba59) #7 0x7f36bd29f8b0 in XML_ParseBuffer (/lib/x86_64-linux-gnu/libexpat.so.1+0xf8b0) #8 0x7f36bd9c9152 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x27152) #9 0x7f36bd9c956b (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2756b) #10 0x7f36bd9c977c (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2777c) #11 0x7f36bd9c9c9e (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x27c9e) #12 0x7f36bd29c4a9 (/lib/x86_64-linux-gnu/libexpat.so.1+0xc4a9) #13 0x7f36bd29ada7 (/lib/x86_64-linux-gnu/libexpat.so.1+0xada7) #14 0x7f36bd29ba59 (/lib/x86_64-linux-gnu/libexpat.so.1+0xba59) #15 0x7f36bd29f8b0 in XML_ParseBuffer (/lib/x86_64-linux-gnu/libexpat.so.1+0xf8b0) #16 0x7f36bd9c9152 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x27152) #17 0x7f36bd9c956b (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2756b) #18 0x7f36bd9bb507 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x19507) #19 0x7f36bd9bb766 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x19766) #20 0x7f36bd9ad926 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0xb926) #21 0x7f36bd9af8c6 in FcConfigSubstituteWithPat (/lib/x86_64-linux-gnu/libfontconfig.so.1+0xd8c6) #22 0x7f36ba21caae (/lib/x86_64-linux-gnu/libpangocairo-1.0.so.0+0xbaae) #23 0x7f36b9b8a6df (/lib/x86_64-linux-gnu/libpangoft2-1.0.so.0+0xc6df) #24 0x7f36b9b88bd9 (/lib/x86_64-linux-gnu/libpangoft2-1.0.so.0+0xabd9) #25 0x7f36b9db218d (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x2418d) #26 0x7f36b9db313b (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x2513b) #27 0x7f36b9db39aa (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x259aa) #28 0x7f36b9db84c8 (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x2a4c8) #29 0x7f36b9db8702 in pango_layout_get_pixel_extents (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x2a702) #30 0x7f36ba05fbb3 in theme_render_frame ../../git/weston/shared/cairo-util.c:586 #31 0x7f36ba06c7b7 in frame_repaint ../../git/weston/shared/frame.c:1071 #32 0x7f36ba07191b in weston_gl_borders_update ../../git/weston/libweston/gl-borders.c:81 #33 0x7f36ba0544c3 in headless_output_update_gl_border ../../git/weston/libweston/backend-headless/headless.c:150 #34 0x7f36ba0545a3 in headless_output_repaint ../../git/weston/libweston/backend-headless/headless.c:165 #35 0x7f36bea58238 in weston_output_repaint ../../git/weston/libweston/compositor.c:3115 #36 0x7f36bea5921d in weston_output_maybe_repaint ../../git/weston/libweston/compositor.c:3186 #37 0x7f36bea5a100 in output_repaint_timer_handler ../../git/weston/libweston/compositor.c:3267 #38 0x7f36beee6766 in wl_timer_heap_dispatch ../../git/wayland/src/event-loop.c:526 #39 0x7f36beee6766 in wl_event_loop_dispatch ../../git/wayland/src/event-loop.c:1020 #40 0x7f36beee41d4 in wl_display_run ../../git/wayland/src/wayland-server.c:1431 #41 0x7f36bfaa3dc3 in wet_main ../../git/weston/compositor/main.c:4080 #42 0x557d4f1e1703 in execute_compositor ../../git/weston/tests/weston-test-fixture-compositor.c:410 #43 0x557d4f1ebd43 in weston_test_harness_execute_as_client ../../git/weston/tests/weston-test-runner.c:534 #44 0x557d4f1c8568 in fixture_setup ../../git/weston/tests/color-icc-output-test.c:462 #45 0x557d4f1c861f in fixture_setup_run_ ../../git/weston/tests/color-icc-output-test.c:464 #46 0x557d4f1ec92e in main ../../git/weston/tests/weston-test-runner.c:682 #47 0x7f36bda4ed09 in __libc_start_main ../csu/libc-start.c:308 #48 0x557d4f1c5a89 in _start (/home/pq/build/weston-meson/tests/test-color-icc-output+0x3da89) Indirect leak of 537 byte(s) in 52 object(s) allocated from: #0 0x7f36bf057817 in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:452 #1 0x7f36bd9c1fa4 in FcValueSave (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x1ffa4) #2 0x7f36bd9c2d5d (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x20d5d) #3 0x7f36bd9c439c (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2239c) #4 0x7f36bd9cb24c (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2924c) #5 0x7f36bd29c4a9 (/lib/x86_64-linux-gnu/libexpat.so.1+0xc4a9) #6 0x7f36bd29ada7 (/lib/x86_64-linux-gnu/libexpat.so.1+0xada7) #7 0x7f36bd29ba59 (/lib/x86_64-linux-gnu/libexpat.so.1+0xba59) #8 0x7f36bd29f8b0 in XML_ParseBuffer (/lib/x86_64-linux-gnu/libexpat.so.1+0xf8b0) #9 0x7f36bd9c9152 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x27152) #10 0x7f36bd9c956b (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2756b) #11 0x7f36bd9c977c (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2777c) #12 0x7f36bd9c9c9e (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x27c9e) #13 0x7f36bd29c4a9 (/lib/x86_64-linux-gnu/libexpat.so.1+0xc4a9) #14 0x7f36bd29ada7 (/lib/x86_64-linux-gnu/libexpat.so.1+0xada7) #15 0x7f36bd29ba59 (/lib/x86_64-linux-gnu/libexpat.so.1+0xba59) #16 0x7f36bd29f8b0 in XML_ParseBuffer (/lib/x86_64-linux-gnu/libexpat.so.1+0xf8b0) #17 0x7f36bd9c9152 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x27152) #18 0x7f36bd9c956b (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2756b) #19 0x7f36bd9bb507 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x19507) #20 0x7f36bd9bb766 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x19766) #21 0x7f36bd9ad926 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0xb926) #22 0x7f36bd9af8c6 in FcConfigSubstituteWithPat (/lib/x86_64-linux-gnu/libfontconfig.so.1+0xd8c6) #23 0x7f36ba21caae (/lib/x86_64-linux-gnu/libpangocairo-1.0.so.0+0xbaae) #24 0x7f36b9b8a6df (/lib/x86_64-linux-gnu/libpangoft2-1.0.so.0+0xc6df) #25 0x7f36b9b88bd9 (/lib/x86_64-linux-gnu/libpangoft2-1.0.so.0+0xabd9) #26 0x7f36b9db218d (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x2418d) #27 0x7f36b9db313b (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x2513b) #28 0x7f36b9db39aa (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x259aa) #29 0x7f36b9db84c8 (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x2a4c8) #30 0x7f36b9db8702 in pango_layout_get_pixel_extents (/lib/x86_64-linux-gnu/libpango-1.0.so.0+0x2a702) #31 0x7f36ba05fbb3 in theme_render_frame ../../git/weston/shared/cairo-util.c:586 #32 0x7f36ba06c7b7 in frame_repaint ../../git/weston/shared/frame.c:1071 #33 0x7f36ba07191b in weston_gl_borders_update ../../git/weston/libweston/gl-borders.c:81 #34 0x7f36ba0544c3 in headless_output_update_gl_border ../../git/weston/libweston/backend-headless/headless.c:150 #35 0x7f36ba0545a3 in headless_output_repaint ../../git/weston/libweston/backend-headless/headless.c:165 #36 0x7f36bea58238 in weston_output_repaint ../../git/weston/libweston/compositor.c:3115 #37 0x7f36bea5921d in weston_output_maybe_repaint ../../git/weston/libweston/compositor.c:3186 #38 0x7f36bea5a100 in output_repaint_timer_handler ../../git/weston/libweston/compositor.c:3267 #39 0x7f36beee6766 in wl_timer_heap_dispatch ../../git/wayland/src/event-loop.c:526 #40 0x7f36beee6766 in wl_event_loop_dispatch ../../git/wayland/src/event-loop.c:1020 #41 0x7f36beee41d4 in wl_display_run ../../git/wayland/src/wayland-server.c:1431 #42 0x7f36bfaa3dc3 in wet_main ../../git/weston/compositor/main.c:4080 #43 0x557d4f1e1703 in execute_compositor ../../git/weston/tests/weston-test-fixture-compositor.c:410 #44 0x557d4f1ebd43 in weston_test_harness_execute_as_client ../../git/weston/tests/weston-test-runner.c:534 #45 0x557d4f1c8568 in fixture_setup ../../git/weston/tests/color-icc-output-test.c:462 #46 0x557d4f1c861f in fixture_setup_run_ ../../git/weston/tests/color-icc-output-test.c:464 #47 0x557d4f1ec92e in main ../../git/weston/tests/weston-test-runner.c:682 #48 0x7f36bda4ed09 in __libc_start_main ../csu/libc-start.c:308 #49 0x557d4f1c5a89 in _start (/home/pq/build/weston-meson/tests/test-color-icc-output+0x3da89) SUMMARY: AddressSanitizer: 9145 byte(s) leaked in 132 allocation(s). We do the clean-up unconditionally because xwayland plugin may also need it, but cannot easily do it itself. This reduces reported leaks in xwayland test too. Signed-off-by: Pekka Paalanen --- libweston/backend-headless/headless.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libweston/backend-headless/headless.c b/libweston/backend-headless/headless.c index 19b5e45c..a7d692d8 100644 --- a/libweston/backend-headless/headless.c +++ b/libweston/backend-headless/headless.c @@ -507,6 +507,8 @@ headless_destroy(struct weston_backend *backend) free(b->formats); free(b); + + cleanup_after_cairo(); } static const struct weston_windowed_output_api api = {