Clean up after each test to avoid ASan reporting leaks.
At few points client_roundtrip() is replaced with client_destroy()
because the latter does a final roundtrip anyway.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
expect_protocol_error() ensures that the connection has failed in the
expected way. To satisfy ASan leak detection, we still need to tear down
everything, including call client_destroy().
client_destroy() needs to check that tear-down does not cause protocol
errors, so it does one last roundtrip that checks that is succeeds. But
if the connection is already down in an expected way, this roundtrip
cannot succeed and must be skipped.
Also moves the roundtrip under 'if (wl_display)', assuming the 'if' is
there for a reason - but obviously that reason was never used as it
would have crashed.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
ASan will detect leaks also outside of the code we build, and sometimes
that external code leaks and we cannot work around it. Then we need to
suppress the leak reports to make our own ASan testing succeed. This
commit only introduces the suppressions file, making use of it CI is for
another time. This file is useful for manual targeted testing as below.
Start by suppressing two functions what weston-keyboard client ends up
calling, suppressing leak reports like these:
Indirect leak of 96 byte(s) in 3 object(s) allocated from:
#0 0x7fc109c3d518 in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9518)
#1 0x7fc109083d18 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x20d18)
#2 0x7fc1090849a7 in FcPatternDuplicate (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x219a7)
#3 0x7fc109adf93e (/lib/x86_64-linux-gnu/libcairo.so.2+0xbb93e)
#4 0x7fc109adfc8d (/lib/x86_64-linux-gnu/libcairo.so.2+0xbbc8d)
#5 0x7fc109aa02e7 in cairo_toy_font_face_create (/lib/x86_64-linux-gnu/libcairo.so.2+0x7c2e7)
#6 0x7fc109aa856c in cairo_select_font_face (/lib/x86_64-linux-gnu/libcairo.so.2+0x8456c)
#7 0x5603cb49a06a in redraw_handler ../../git/weston/clients/keyboard.c:378
#8 0x5603cb4b506b in widget_redraw ../../git/weston/clients/window.c:4520
#9 0x5603cb4b55da in surface_redraw ../../git/weston/clients/window.c:4578
#10 0x5603cb4b5750 in idle_redraw ../../git/weston/clients/window.c:4607
#11 0x5603cb4bebe3 in display_run ../../git/weston/clients/window.c:6525
#12 0x5603cb49e55d in main ../../git/weston/clients/keyboard.c:1054
#13 0x7fc1092a709a in __libc_start_main ../csu/libc-start.c:308
#14 0x5603cb499019 in _start (/home/pq/build/weston-meson/clients/weston-keyboard+0x19019)
Indirect leak of 528 byte(s) in 51 object(s) allocated from:
#0 0x7fc109b8e810 in strdup (/lib/x86_64-linux-gnu/libasan.so.5+0x3a810)
#1 0x7fc109082fc4 in FcValueSave (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x1ffc4)
#2 0x7fc109083d2e (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x20d2e)
#3 0x7fc1090852c7 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x222c7)
#4 0x7fc10908c28b (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2928b)
#5 0x7fc108603a15 (/lib/x86_64-linux-gnu/libexpat.so.1+0xba15)
#6 0x7fc1086044bb (/lib/x86_64-linux-gnu/libexpat.so.1+0xc4bb)
#7 0x7fc108601f8a (/lib/x86_64-linux-gnu/libexpat.so.1+0x9f8a)
#8 0x7fc108602e7a (/lib/x86_64-linux-gnu/libexpat.so.1+0xae7a)
#9 0x7fc108606a37 in XML_ParseBuffer (/lib/x86_64-linux-gnu/libexpat.so.1+0xea37)
#10 0x7fc10908a0fa (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x270fa)
#11 0x7fc10908a519 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x27519)
#12 0x7fc10908a73a (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2773a)
#13 0x7fc10908b48f (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2848f)
#14 0x7fc108603a15 (/lib/x86_64-linux-gnu/libexpat.so.1+0xba15)
#15 0x7fc1086044bb (/lib/x86_64-linux-gnu/libexpat.so.1+0xc4bb)
#16 0x7fc108601f8a (/lib/x86_64-linux-gnu/libexpat.so.1+0x9f8a)
#17 0x7fc108602e7a (/lib/x86_64-linux-gnu/libexpat.so.1+0xae7a)
#18 0x7fc108606a37 in XML_ParseBuffer (/lib/x86_64-linux-gnu/libexpat.so.1+0xea37)
#19 0x7fc10908a0fa (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x270fa)
#20 0x7fc10908a519 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x27519)
#21 0x7fc10907c4b3 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x194b3)
#22 0x7fc10907c715 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x19715)
#23 0x7fc10906e8e6 (/lib/x86_64-linux-gnu/libfontconfig.so.1+0xb8e6)
#24 0x7fc109070928 in FcConfigSubstituteWithPat (/lib/x86_64-linux-gnu/libfontconfig.so.1+0xd928)
#25 0x7fc109ae2d6b (/lib/x86_64-linux-gnu/libcairo.so.2+0xbed6b)
#26 0x7fc109a8aba2 in cairo_scaled_font_create (/lib/x86_64-linux-gnu/libcairo.so.2+0x66ba2)
#27 0x7fc109a50d1d (/lib/x86_64-linux-gnu/libcairo.so.2+0x2cd1d)
#28 0x7fc109a53be0 (/lib/x86_64-linux-gnu/libcairo.so.2+0x2fbe0)
#29 0x7fc109a4c1df (/lib/x86_64-linux-gnu/libcairo.so.2+0x281df)
#30 0x7fc109aa8dab in cairo_text_extents (/lib/x86_64-linux-gnu/libcairo.so.2+0x84dab)
#31 0x5603cb499af3 in draw_key ../../git/weston/clients/keyboard.c:329
#32 0x5603cb49a30c in redraw_handler ../../git/weston/clients/keyboard.c:392
#33 0x5603cb4b506b in widget_redraw ../../git/weston/clients/window.c:4520
#34 0x5603cb4b55da in surface_redraw ../../git/weston/clients/window.c:4578
#35 0x5603cb4b5750 in idle_redraw ../../git/weston/clients/window.c:4607
#36 0x5603cb4bebe3 in display_run ../../git/weston/clients/window.c:6525
#37 0x5603cb49e55d in main ../../git/weston/clients/keyboard.c:1054
#38 0x7fc1092a709a in __libc_start_main ../csu/libc-start.c:308
#39 0x5603cb499019 in _start (/home/pq/build/weston-meson/clients/weston-keyboard+0x19019)
With the command line
ASAN_OPTIONS=fast_unwind_on_malloc=0,malloc_context_size=50 \
LSAN_OPTIONS=suppressions=/home/pq/git/weston/.gitlab-ci/leak-sanitizer.supp \
./tests/test-viewporter test_viewporter_double_create
Suppressions used:
count bytes template
5 357 cairo_select_font_face
130 9104 cairo_text_extents
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Another patch will want to call global_destroy() too.
Pure refactoring, no functional change.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This fixes a bunch of leaks when trying to run a Weston test with
desktop-shell, which spawns weston-keyboard.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Trying to run viewporter-test with ASan leak checking,
weston-desktop-shell helper client reports many leaks, because the
compositor quits before the client can start. Hence the
wl_display_roundtrip() fails.
Clean up by calling display_destroy() when wl_display_roundtrip() fails.
It's late enough that all kinds of things may have been allocated, so a
special local tear-down path is not feasible.
To make that work, display_destroy() must handle many things that might
be NULL which normally aren't. Also display_create() needs to initialize
lists early enough so that cleaning them up works.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Currently, Weston clients update the pointer cursor by first issuing
a wl_surface.commit request to update the buffer, then a
wl_pointer.set_cursor request to update the hotspot. This causes an
issue because buffer and hotspot aren't updated atomically: in-between
the two requests, the buffer is new but the hotspot is old.
To fix this issue, create a new surface each time the cursor is
updated.
Signed-off-by: Simon Ser <contact@emersion.fr>
struct weston_test_surface in the test harness' compositor plugin had no
tear down code, which lead to ASan report on alpha-blending test:
Direct leak of 64 byte(s) in 2 object(s) allocated from:
#0 0x7f8931f10330 in __interceptor_malloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9330)
#1 0x7f892d934425 in move_surface ../../git/weston/tests/weston-test.c:181
#2 0x7f893159d8ed in ffi_call_unix64 (/lib/x86_64-linux-gnu/libffi.so.6+0x68ed)
While at it, let's do this properly for once:
- put the creation in a new function
- hook up to the weston_surface destroy signal so this actually gets
freed (fixes the leak)
- check that we don't overwrite another surface role
- check that committed_private actually is ours
- set the surface label func so it gets properly listed in debugs and
traces
- use the proper surface role setup call, so no-one stomps on anyones
toes if a test makes a mistake by using a wrong wl_surface
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Fixes a leak found by ASan in alpha-blending-test.
Direct leak of 160 byte(s) in 2 object(s) allocated from:
#0 0x7f511fe11518 in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9518)
#1 0x7f511fc76373 in zalloc ../../git/wayland/src/wayland-private.h:232
#2 0x7f511fc76373 in proxy_create ../../git/wayland/src/wayland-client.c:422
#3 0x7f511fc79dcc in create_outgoing_proxy ../../git/wayland/src/wayland-client.c:651
#4 0x7f511fc79dcc in wl_proxy_marshal_array_constructor_versioned ../../git/wayland/src/wayland-client.c:736
#5 0x7f511fc7b17b in wl_proxy_marshal_constructor_versioned ../../git/wayland/src/wayland-client.c:873
#6 0x5583e5348f43 in wl_registry_bind /home/pq/local/include/wayland-client-protocol.h:1165
#7 0x5583e534cfbe in handle_global ../../git/weston/tests/weston-test-client-helper.c:800
#8 0x7f511f34b8ed in ffi_call_unix64 (/lib/x86_64-linux-gnu/libffi.so.6+0x68ed)
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Fixed a leak found by ASan:
Direct leak of 160 byte(s) in 2 object(s) allocated from:
#0 0x7f511fe11518 in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9518)
#1 0x7f511fc76373 in zalloc ../../git/wayland/src/wayland-private.h:232
#2 0x7f511fc76373 in proxy_create ../../git/wayland/src/wayland-client.c:422
#3 0x7f511fc79dcc in create_outgoing_proxy ../../git/wayland/src/wayland-client.c:651
#4 0x7f511fc79dcc in wl_proxy_marshal_array_constructor_versioned ../../git/wayland/src/wayland-client.c:736
#5 0x7f511fc7b17b in wl_proxy_marshal_constructor_versioned ../../git/wayland/src/wayland-client.c:873
#6 0x5583e5348f43 in wl_registry_bind /home/pq/local/include/wayland-client-protocol.h:1165
#7 0x5583e535140b in bind_to_singleton_global ../../git/weston/tests/weston-test-client-helper.c:1863
#8 0x5583e5348752 in alpha_blend_monotonic ../../git/weston/tests/alpha-blending-test.c:219
#9 0x5583e5348571 in wrapalpha_blend_monotonic ../../git/weston/tests/alpha-blending-test.c:200
#10 0x5583e53554cc in run_test ../../git/weston/tests/weston-test-runner.c:162
#11 0x5583e5355b6d in run_case ../../git/weston/tests/weston-test-runner.c:277
#12 0x5583e5355913 in for_each_test_case ../../git/weston/tests/weston-test-runner.c:235
#13 0x5583e5355df5 in testsuite_run ../../git/weston/tests/weston-test-runner.c:311
#14 0x7f511aaaf752 in client_thread_routine ../../git/weston/tests/weston-test.c:404
#15 0x7f511f88cfa2 in start_thread /build/glibc-vjB4T1/glibc-2.28/nptl/pthread_create.c:486
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Fixes a definitely lost:
== 56 bytes in 1 blocks are definitely lost in loss record 16 of 45
== at 0x48450F8: malloc (vg_replace_malloc.c:309)
== by 0x4B55E93: wl_event_loop_add_timer (event-loop.c:197)
== by 0x4126CF: weston_compositor_create (in /usr/local/bin/weston)
== by 0x409997: main (in /usr/local/bin/weston)
Signed-off-by: Lujin Wang <luwang@nvidia.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
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>
This new function is callable explicitly, unlike the old function that
used to have the same name.
This will be needed when tearing down what
weston_desktop_xwayland_init() puts up.
Since calling weston_desktop_client_destroy() for an external client
(one that has a wl_resource for this) is a bug, add asserts to prevent
it. This will only be needed for the internal client: XWM.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This function here is a wl_resource destructor, but we will need another
function for externally triggered destroy when wl_resource does not
exist.
Rename the existing function, because the old name fits better the new
function to be written.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This ensures the layers are torn down properly.
See commit: libweston: add weston_layer_fini()
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This ensures the layers are torn down properly.
See commit: libweston: add weston_layer_fini()
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This ensures the layers are torn down properly.
See commit: libweston: add weston_layer_fini()
There would be a lot more to tear down here, but that is for another
time.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This ensures the layers are torn down properly.
See commit: libweston: add weston_layer_fini()
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Layers did not have a fini sequence before, which means the compositor
layer list might have stale pointers temporarily when shutting down. A
bigger problem might be having views linger after the destruction of the
layer.
These problems were not observed yet, but if they exist, this patch
should help to find them and then fix them.
The check in weston_compositor_shutdown() is not an assert yet, because
it will trigger until all components call weston_layer_fini() correctly.
Some components do not even have a tear-down function to call it from at
all, like fullscreen-shell.
The same with the check in weston_layer_fini().
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
$FDO_CI_CONCURRENT is provided by in the CI environment by the fd.o
GitLab runners to tell us how many parallel processes would be 'good' to
use.
Use this to override the default Ninja invocation which uses as many
CPUs as available, and instead tell it to use as many parallel processes
as the runner thinks we should during the build process.
Tests are invoked using `meson test` inside a virtme/QEmu VM; whilst
Meson's test backend will use as many processors as availble, virtme
will by default create a single-CPU VM. So if we create a VM with as
many CPUs as we should have parallel processes, we can let it use all of
them. This also requires quadrupling the requested RAM so ASan doesn't
force us straight into OOM.
Suggested by @daenzer.
Signed-off-by: Daniel Stone <daniels@collabora.com>
These are all the remaining places that still use the global view_list,
and cannot avoid it. Add a comment to explain why in each.
Now all places that use view_list have been audited for paint node
lists.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Iterate paint nodes instead of the global view list. Right now this does
not change behavior.
This is a step towards using per-output view lists that can then be
optimized for the output in libweston core.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Iterate paint nodes instead of the global view list. Right now this does
not change behavior.
This is a step towards using per-output view lists that can then be
optimized for the output in libweston core.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Iterate paint nodes instead of the global view list. Right now this does
not change behavior.
This is a step towards using per-output view lists that can then be
optimized for the output in libweston core.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Iterate paint nodes instead of the global view list. Right now this does
not change behavior.
This is a step towards using per-output view lists that can then be
optimized for the output in libweston core.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Iterate paint nodes instead of the global view list. Right now this does
not change behavior.
This is a step towards using per-output view lists that can then be
optimized for the output in libweston core.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This patch creates a per-output paint node list in the same z-order as
the global view_list in weston_compositor.
The next step is to switch output repaints and backends to use the
z-order list instead of view_list.
Having a per-output paint node list for repaints allows including only
those paint nodes that actually contribute to the output image, so that
completely occluded and out-of-screen views can be ignored in libweston
core already.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This new object is created for every surface-view-output triplet. As
there is always exactly one surface for a view and it does not change
during a view's lifetime, this is really for a view-output pair or a
surface-output pair.
The object is created on-demand as a part of preparing for an output
repaint, so it applies only to surfaces that are going through repaint.
A prerequisite for that is that the surface is mapped, which means it
has a mapped view.
When any one of surface or view gets destroyed or output gets disabled,
all related paint nodes are destroyed.
In future, paint node will be useful for caching surface-output or
view-output pair dependent data:
- damage regions for overlapping outputs
- color transformations
- backend-specific bookkeeping (e.g. DRM KMS plane assigments)
- per-output repaint lists
- surface geometry transformed into output space
Suggested by Daniel Stone in
https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/582#note_899406
PS. The call in weston_view_destroy() to
weston_compositor_build_view_list() might be so that if the view has
sub-surfaces, rebuilding the view list removes those those too and
automagically deletes their views.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
While this is harmless because gbm_bo_create_with_modifiers will just
fail, it's easy to misunderstand that gbm_bo_create_with_modifiers
accepts MOD_INVALID. Let's just keep modifiers_count to zero instead
and stop even trying to call that function with invalid input.
Stop using modifiers_count to decide whether the compositor supports a
format. Instead use a separate format_supported flag.
Signed-off-by: Simon Ser <contact@emersion.fr>
References: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7601#note_778845
Running under ASan introduces a good amount of overhead. Using the Meson
test wrapper rather than invoking a Ninja target lets us set a timeout
multiplier, which we smash up pretty high to account for this overhead
and prevent some of the larger tests from hitting timeout.
Signed-off-by: Daniel Stone <daniels@collabora.com>
The old job names were really long, so long that Gitlab web UI had to
almost always ellipsize them, showing only the beginning which is the
same fof the two and hiding the part that actually matters.
Rename the templates and the jobs to be shorter and more descriptive.
Meson is the only tool we build with. All builds are native. Default
options is a long way to say full-featured and besides libseat was not
even default yet we build it.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
I'm tired of scrolling through that flood when looking at CI logs. It's
just listing every gcno, gcda and c file name as it parses them.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Change BUILDDIR and PREFIX from exported shell variables into CI
variables. This way they can be used in CI configuration, e.g.
artifacts.
The main reason for this change is that it makes it possible to use
these variables in after_script, which is not possible with shell
variables as the values do not carry over there.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Use the real name of the seat instead of calling each seat 'default'. This makes
it easier to identify the current seat in a multi-seat environment.
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
This change fixes the "touch-up" operation to clear "data_source"
by setting "seat" to NULL. This operation is done in the mouse button
release operation, but seems to have been forgotten in the "touch up"
case.
Forgetting this operation causes weston to send a "premature finish
request" error to the client which causes the client to exit.
This issue can be reproduced with the "weston-dnd" program by performing
a drag-and-drop operation with a touch input device. Once the drag
is released, the weston-dnd program will exit with an error.
Signed-off-by: Jonathan Marler <johnnymarler@gmail.com>
If sprites_are_broken, then we will only ever arrive in renderer_only
mode, so this case will be caught by the checks above.
Signed-off-by: Daniel Stone <daniels@collabora.com>
Avoids an user-after-free when destroying the surface, like in the
following ASAN message:
==25180==ERROR: AddressSanitizer: heap-use-after-free on address 0x6060000589d8 at pc 0x7ff70a4f7102 bp 0x7fff8f7e13b0 sp 0x7fff8f7e13a8
READ of size 8 at 0x6060000589d8 thread T0
#0 0x7ff70a4f7101 in weston_schedule_surface_protection_update ../libweston/compositor.c:1163
#1 0x7ff70a4f743b in weston_surface_update_output_mask ../libweston/compositor.c:1212
#2 0x7ff70a4f7a47 in weston_surface_assign_output ../libweston/compositor.c:1298
#3 0x7ff70a4f7f44 in weston_view_assign_output ../libweston/compositor.c:1348
#4 0x7ff70a4fa12f in weston_view_update_transform ../libweston/compositor.c:1589
#5 0x7ff70a4ffc20 in view_list_add ../libweston/compositor.c:2657
#6 0x7ff70a5000ee in weston_compositor_build_view_list ../libweston/compositor.c:2688
#7 0x7ff70a4fd577 in weston_view_destroy ../libweston/compositor.c:2202
#8 0x7ff70a4fd7df in weston_surface_destroy ../libweston/compositor.c:2239
#9 0x7ff70a4fdbb0 in destroy_surface ../libweston/compositor.c:2285
#10 0x7ff70a4a2d3e in destroy_resource ../src/wayland-server.c:723
#11 0x7ff70a4a8940 in for_each_helper ../src/wayland-util.c:372
#12 0x7ff70a4a8e1f in wl_map_for_each ../src/wayland-util.c:385
#13 0x7ff70a4a3748 in wl_client_destroy ../src/wayland-server.c:882
#14 0x7ff6fe04e866 in shell_destroy ../desktop-shell/shell.c:5004
#15 0x7ff70a4ee923 in wl_signal_emit /home/mvlad/install-amd64/include/wayland-server-core.h:481
#16 0x7ff70a51598d in weston_compositor_destroy ../libweston/compositor.c:7903
#17 0x7ff70a903a58 in wet_main ../compositor/main.c:3493
#18 0x560de7b3b179 in main ../compositor/executable.c:33
#19 0x7ff70a73ecc9 in __libc_start_main ../csu/libc-start.c:308
#20 0x560de7b3b099 in _start (/home/mvlad/install-amd64/bin/weston+0x1099)
0x6060000589d8 is located 56 bytes inside of 64-byte region [0x6060000589a0,0x6060000589e0)
freed by thread T0 here:
#0 0x7ff70a9d3b6f in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.6+0xa9b6f)
#1 0x7ff70a5167d2 in cp_destroy_listener ../libweston/content-protection.c:193
#2 0x7ff70a4ee923 in wl_signal_emit /home/mvlad/install-amd64/include/wayland-server-core.h:481
#3 0x7ff70a51598d in weston_compositor_destroy ../libweston/compositor.c:7903
#4 0x7ff70a903a58 in wet_main ../compositor/main.c:3493
#5 0x560de7b3b179 in main ../compositor/executable.c:33
#6 0x7ff70a73ecc9 in __libc_start_main ../csu/libc-start.c:308
previously allocated by thread T0 here:
#0 0x7ff70a9d4037 in calloc (/usr/lib/x86_64-linux-gnu/libasan.so.6+0xaa037)
#1 0x7ff70a5160aa in zalloc ../include/libweston/zalloc.h:38
#2 0x7ff70a516cda in weston_compositor_enable_content_protection ../libweston/content-protection.c:329
#3 0x7ff7070247e0 in drm_backend_create ../libweston/backend-drm/drm.c:3180
#4 0x7ff707024cae in weston_backend_init ../libweston/backend-drm/drm.c:3250
#5 0x7ff70a515d02 in weston_compositor_load_backend ../libweston/compositor.c:7999
#6 0x7ff70a8fbcfb in load_drm_backend ../compositor/main.c:2614
#7 0x7ff70a900b46 in load_backend ../compositor/main.c:3103
#8 0x7ff70a902ecd in wet_main ../compositor/main.c:3380
#9 0x560de7b3b179 in main ../compositor/executable.c:33
#10 0x7ff70a73ecc9 in __libc_start_main ../csu/libc-start.c:308
SUMMARY: AddressSanitizer: heap-use-after-free ../libweston/compositor.c:1163 in weston_schedule_surface_protection_update
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Use address sanitizer to catch use-after-free and other errors when
running the test suite.
Leak detection is disabled, because currently there are too many leaks,
making almost all tests fail otherwise.
The atexit=1 is for verifying that ASan was actually used.
The default 128 MB of RAM in the qemu machine leads to oom-killer
killing most tests, so bump the memory size to 1 GB.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Found by Address sanitizer on test-devices:
==10640==ERROR: AddressSanitizer: heap-use-after-free on address 0x60c000000580 at pc 0x7fa0f050dcd1 bp 0x7fff41c908e0 sp 0x7fff41c908d8
WRITE of size 8 at 0x60c000000580 thread T0
#0 0x7fa0f050dcd0 in unbind_input_method ../../git/weston/compositor/text-backend.c:852
#1 0x7fa0efd1b20d in destroy_resource ../../git/wayland/src/wayland-server.c:724
#2 0x7fa0efd1f7f1 in for_each_helper ../../git/wayland/src/wayland-util.c:372
#3 0x7fa0efd1fcde in wl_map_for_each ../../git/wayland/src/wayland-util.c:385
#4 0x7fa0efd1b35c in wl_client_destroy ../../git/wayland/src/wayland-server.c:883
#5 0x7fa0f050ea82 in text_backend_destroy ../../git/weston/compositor/text-backend.c:1067
#6 0x7fa0ebb69f2f in shell_destroy ../../git/weston/desktop-shell/shell.c:5012
#7 0x7fa0efd55933 in wl_signal_emit /home/pq/local/include/wayland-server-core.h:478
#8 0x7fa0efd7d061 in weston_compositor_destroy ../../git/weston/libweston/compositor.c:7896
#9 0x7fa0f050a349 in wet_main ../../git/weston/compositor/main.c:3493
#10 0x559c1e794354 in execute_compositor ../../git/weston/tests/weston-test-fixture-compositor.c:432
#11 0x559c1e797dc0 in weston_test_harness_execute_as_client ../../git/weston/tests/weston-test-runner.c:528
#12 0x559c1e786ab8 in fixture_setup ../../git/weston/tests/devices-test.c:39
#13 0x559c1e786b3a in fixture_setup_run_ ../../git/weston/tests/devices-test.c:41
#14 0x559c1e798375 in main ../../git/weston/tests/weston-test-runner.c:661
#15 0x7fa0f016e09a in __libc_start_main ../csu/libc-start.c:308
#16 0x559c1e786769 in _start (/home/pq/build/weston-meson/tests/test-devices+0xc769)
0x60c000000580 is located 0 bytes inside of 120-byte region [0x60c000000580,0x60c0000005f8)
freed by thread T0 here:
#0 0x7fa0f0618fb0 in __interceptor_free (/lib/x86_64-linux-gnu/libasan.so.5+0xe8fb0)
#1 0x7fa0f050df1d in input_method_notifier_destroy ../../git/weston/compositor/text-backend.c:902
#2 0x7fa0efd86d77 in wl_signal_emit /home/pq/local/include/wayland-server-core.h:478
#3 0x7fa0efd98086 in weston_seat_release ../../git/weston/libweston/input.c:3475
#4 0x7fa0ebb0d002 in test_seat_release ../../git/weston/tests/weston-test.c:132
#5 0x7fa0ebb0e197 in device_release ../../git/weston/tests/weston-test.c:314
#6 0x7fa0efca88ed in ffi_call_unix64 (/lib/x86_64-linux-gnu/libffi.so.6+0x68ed)
previously allocated by thread T0 here:
#0 0x7fa0f0619518 in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9518)
#1 0x7fa0f050a8bf in zalloc ../../git/weston/include/libweston/zalloc.h:38
#2 0x7fa0f050e6f1 in text_backend_seat_created ../../git/weston/compositor/text-backend.c:1011
#3 0x7fa0f050e947 in handle_seat_created ../../git/weston/compositor/text-backend.c:1040
#4 0x7fa0efd86d77 in wl_signal_emit /home/pq/local/include/wayland-server-core.h:478
#5 0x7fa0efd97d57 in weston_seat_init ../../git/weston/libweston/input.c:3440
#6 0x7fa0ebb0ce4b in test_seat_init ../../git/weston/tests/weston-test.c:110
#7 0x7fa0ebb0f699 in wet_module_init ../../git/weston/tests/weston-test.c:592
#8 0x7fa0f04f8d69 in wet_load_module ../../git/weston/compositor/main.c:941
#9 0x7fa0f04f914d in load_modules ../../git/weston/compositor/main.c:1012
#10 0x7fa0f0509ec1 in wet_main ../../git/weston/compositor/main.c:3441
#11 0x559c1e794354 in execute_compositor ../../git/weston/tests/weston-test-fixture-compositor.c:432
#12 0x559c1e797dc0 in weston_test_harness_execute_as_client ../../git/weston/tests/weston-test-runner.c:528
#13 0x559c1e786ab8 in fixture_setup ../../git/weston/tests/devices-test.c:39
#14 0x559c1e786b3a in fixture_setup_run_ ../../git/weston/tests/devices-test.c:41
#15 0x559c1e798375 in main ../../git/weston/tests/weston-test-runner.c:661
#16 0x7fa0f016e09a in __libc_start_main ../csu/libc-start.c:308
Fix UAF by resetting wl_resource user data, and ensuring it is valid
before used.
Setting seat->input_method to NULL may not be necessary since it is
being called from seat destroy listener, but added just in case.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Weston internals and Wayland clients assume that output presentation
clock cannot go backwards. Therefore require unconditionally that KMS
uses the monotonic clock.
The kernel unconditionally supports DRM_CAP_TIMESTAMP_MONOTONIC. See:
commit 25e1a79874eb3821d93310c908cc0a81b47af060
Author: Arnd Bergmann <arnd@arndb.de>
Date: Wed Oct 11 17:20:13 2017 +0200
drm: vblank: remove drm_timestamp_monotonic parameter
That one removed the final possibility of DRM_CAP_TIMESTAMP_MONOTONIC
being false, by removing the module option. But even before that, all
drivers have been supporting monotonic, since
commit c61eef726a78ae77b6ce223d01ea2130f465fe5c
Author: Imre Deak <imre.deak@intel.com>
Date: Tue Oct 23 18:53:26 2012 +0000
drm: add support for monotonic vblank timestamps
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This drops the software presentation clocks that could jump backwards.
See the previous commit "libweston: assert frame times never go
backwards" for the rationale.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Adding this check was prompted by
https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/609
There is no reason to allow frame times jump backwards, and apparently
we already have code that makes that assumption.
DRM KMS uses CLOCK_MONOTONIC as the vblank and page flip timestamps,
which by definition cannot go backwards. Other backends call
weston_compositor_set_presentation_clock_software().
Frame times are also reported directly to Wayland clients via
presentation-time extension, and clients too will not expect that the
timestamp could go backwards.
So make sure time can never go backwards.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>