GDBusProxy: Race conditions during initialization of GDBusObjectManagerClient object
We are using glib 2.50.3 and we have rarely encountered race conditions with GDBusObjectManagerClient object initialization (with NetworkManager client 1.12.4). The file is gio/gdbusobjectmanagerclient.c.
First race condition:
- GetManagedObject is called by dbus to initialize cache values.
- A PropertiesChanged signal is received (during or just before GetManagedObject result treatment) without InterfacesAdded before (because the interface already existed). The signal is discarded because the object proxy is not in the hash table (map_object_path_to_object_proxy).
- GetManagedObject result is received with an old value of the property: the cache is initialized with this wrong value and it will never be updated until a new PropertiesChanged signal is received.
Second race condition:
- GetManagedObject is called by dbus to initialize cache values.
- InterfacesAdded and PropertiesChanged signals are received for a new property (during or just before GetManagedObject result treatment). The cache is updated with this value.
- GetManagedObject result is received with an old value of the property: the cache is overwritten with this wrong value and it will never be updated until a new PropertiesChanged signal is received.
Unfortunately, we did not found a way to fix these race conditions.
- One solution should be to treat the signals (PropertiesChanged for example) after the end of GetManagedObject result treatment.
- Moreover, discard cache update in add_interfaces if the interface already exists should fix the second race condition but not the first one.
This issue looks similar to #867 but the proposed patch is no more applicable.
Do you have a way to fix or prevent this issue?