actor-offscreen-redirect test has uninitialized stack data, hangs when the obvious fix is applied
Running the actor-offscreen-redirect test under valgrind indicates a use of uninitialized data:
$ xvfb-run -a env GDK_BACKEND=x11 valgrind /usr/lib/x86_64-linux-gnu/installed-tests/clutter/actor-offscreen-redirect --tap
# Start of actor tests
# Start of offscreen tests
==13864== Conditional jump or move depends on uninitialised value(s)
==13864== at 0x10AD7C: actor_offscreen_redirect (actor-offscreen-redirect.c:331)
==13864== by 0x10AD7C: actor_offscreen_redirect (actor-offscreen-redirect.c:299)
==13864== by 0x492F889: clutter_test_func_wrapper (clutter-test-utils.c:138)
==13864== by 0x4B6F3BD: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6000.6)
This is the variable 'data' here:
static void
actor_offscreen_redirect (void)
{
Data data;
... data.was_painted is never initialized ...
while (!data.was_painted)
g_main_context_iteration (NULL, FALSE);
}
It seems that data.was_painted was intended to be initialized to FALSE (all-zeroes), but this never actually happened. If the uninitialized value of data.was_painted happens to be nonzero, this results in basically the entire test being skipped - we never enter the main loop, and never have the opportunity for the test to hang while waiting for a paint signal that will never happen.
Adding some debug code to hexdump the contents of the data struct reveals that gcc-9 -O1, or gcc-9 -O2 with -fno-tree-pre, fairly reliably fills data.was_painted with a nonzero value, so most of the test is effectively never run. gcc-9 -O2 fills it with zeroes, so the test runs.
After applying the obvious fix
- Data data;
+ Data data = {};
or when compiling with gcc-9 -O2, the paint signal never happens (at least in my testing) and the test hangs. With a quick hack to add some more debug messages I get:
# random seed: R02S7604fa56ae42aabac603dcf767c6b987
1..1
# Start of actor tests
# Start of offscreen tests
# Clutter-Conform-DEBUG: in run_verify
# Clutter-Conform-DEBUG: in verify_redraw
# Clutter-Conform-DEBUG: queueing redraw
# Clutter-Conform-DEBUG: running main loop
(time passes, test does not terminate)