GNOME Bugzilla – Bug 635852
gdbus/connection/life-cycle unit test fails sometimes
Last modified: 2018-05-24 12:54:39 UTC
Created attachment 175310 [details] [review] proposed fix for test_connection_life_cycle() unit test Running glib unit test will sometimes fail with following error: TEST: gdbus-connection... (pid=21321) /gdbus/connection/basic: OK /gdbus/connection/life-cycle: ** ERROR:/home/elmir/fmwr/P3301-lfp/libs/glib/glib/gio/tests/gdbus-connection.c:271:test_connection_life_cycle: Timed out waiting for single ref FAIL GTester: last random seed: R02S6152837b2e17d4bed141dc77048e192f /bin/sh: line 1: 19787 Terminated MALLOC_CHECK_=2 MALLOC_PERTURB_=$((${RANDOM:-256} % 256)) ../../glib/gtester --verbose memory-input-stream memory-output-stream readwrite g-file g-file-info converter-stream data-input-stream data-output-stream g-icon buffered-input-stream buffered-output-stream sleepy-stream filter-streams volumemonitor simple-async-result srvtarget contexts gsettings gschema-compile async-close-output-stream gdbus-addresses network-address gdbus-message gdbus-connection gdbus-connection-slow gdbus-names gdbus-proxy-well-known-name gdbus-introspection gdbus-threading gdbus-export gdbus-error gdbus-peer gdbus-exit-on-close gdbus-non-socket gdbus-bz627724 file live-g-file unix-fd When the test fails, the GDBusConnection object's 'closed' signal is never emmited, and emit_closed_data_free() is never run. Thus the GDBusConnection ref-count is stuck at 2. Probably the reason the test only fails sometimes, is that the unit test code takes differenct paths depending on threads timing. After the session_bus_down() call, the _g_assert_signal_received() will not be called if connection->closed = TRUE (gdbusconnection.c:1201) is executed before the call to g_dbus_connection_is_closed(). When the _g_assert_signal_received() is not called, the 'closed' signal is never emitted. I guess this is becouse there is no main-loop running at that point. A call to _g_assert_signal_receive() will create and run the main-loop, thus making it possible for the signal to be emitted. I propose to change the unit test to always make a call to _g_assert_signal_received(), and the check that connection have been closed and unrefed, see the attached patch.
I can confirm this error appears from time to time when building tests. Could upstream take a look on suggested patch to "approve" it if possible? Thanks a lot
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/377.