https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91491
Simon McVittie <smcv at debian dot org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |smcv at debian dot org --- Comment #2 from Simon McVittie <smcv at debian dot org> --- > where does it actually hang? The GLib tests don't hang. The smallest reproducer we have is unfortunately still really complicated. The test-case that hangs is to install precompiled test binaries from the Clutter graphics library, from the https://packages.debian.org/unstable/clutter-1.0-tests Debian package, and run one of those (actor-offscreen-redirect is known to be affected but is not the only one), with the GLib library under test placed in the LD_LIBRARY_PATH. The test runs a GLib event loop (a poll-based event loop similar to libevent/libuv/any other general-purpose event loop library), and expects a callback attached to the Clutter graphics library's rendering path to call g_main_loop_quit(), which "wakes up" the main loop by writing to a pipe-to-self or eventfd, then broadcasting on a condition variable. In the cases where the test fails, the failure mode is that the callback that should have run g_main_loop_quit() is never reached. I think this may be something to do with the "paint clock" in Clutter that aims to draw animated window contents once per 60Hz screen refresh, but I don't know Clutter well enough to know what, specifically, should happen but does not. At the moment I have no idea why changing the optimizations that are applied to test_run_seed() (which is part of GLib's unit test framework, and computes a predictable seed for random numbers generated during a unit test) would have an effect on the Clutter graphics library's X11 rendering, or on whether the event loop terminates. GLib's own test suite still passes, even in the builds that break the Clutter test - so the event loop isn't *completely* broken. > But Simon says it's broken when > compilng test_run_seed with -O1 ... Sorry, where did I say that? I don't think that's the case. Summary of my findings, where "good" means the Clutter test passes, and "bad" means the failure mode described above: * all of GLib with gcc-8 -O2: good * all of GLib with gcc-9 -O2: bad * all of GLib with gcc-9 -O1: good * all of GLib with gcc-9 -O2, except gtestutils.c with -O1: good * all of GLib with gcc-9 -O2, except test_run_seed() reduced to -O1 via an __attribute__: good * all of GLib with gcc-9 -O2, except test_run_seed() with __attribute__((optimize("no-tree-pre"))): good > so you > mean that if you compile the file with -O2 but disable PRE on just > test_run_seed() the testcase works? Yes. This was enough to get the "good" result: https://salsa.debian.org/gnome-team/glib/blob/debian/2.60.6-2/debian/patches/debian/Disable-an-optimization-when-building-with-gcc-9.patch