After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 754794 - [PATCH] libnm: don't add objects to cache until they're async-inited
[PATCH] libnm: don't add objects to cache until they're async-inited
Status: RESOLVED FIXED
Product: NetworkManager
Classification: Platform
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: NetworkManager maintainer(s)
NetworkManager maintainer(s)
: 754767 (view as bug list)
Depends on:
Blocks: nm-review
 
 
Reported: 2015-09-09 17:43 UTC by Lubomir Rintel
Modified: 2015-10-06 13:18 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
libnm: don't add objects to cache until they're async-inited (1.72 KB, text/plain)
2015-09-09 17:43 UTC, Lubomir Rintel
  Details
A new fix (2.85 KB, text/plain)
2015-09-26 06:55 UTC, Lubomir Rintel
  Details
A new fix (3.01 KB, text/plain)
2015-09-28 19:30 UTC, Lubomir Rintel
  Details
A fixed version of the fix for a fix (3.92 KB, text/plain)
2015-10-05 16:12 UTC, Lubomir Rintel
  Details
fixup! libnm: avoid notifying for objects until they're async-inited (2.41 KB, patch)
2015-10-05 17:03 UTC, Thomas Haller
none Details | Review

Description Lubomir Rintel 2015-09-09 17:43:06 UTC
Created attachment 311014 [details]
libnm: don't add objects to cache until they're async-inited

Otherwise the uninitializeded objects could be prematurely signalled if their
paths are seen twice in quick succession. This happens when you have ethernet
hardware and add an ethernet connection -- it's immediatelly added to
AvialableConnections and the property reload signals the object addition
before the NMRemoteSettings's GetSettings() finishes:

  # nmcli c add type ethernet autoconnect no ifname '*'
  (process:4610): libnm-CRITICAL **: nm_connection_get_id: assertion 's_con != NULL' failed
  Connection '(null)' ((null)) successfully added.
  #
Comment 1 Thomas Haller 2015-09-10 09:38:09 UTC
this is a duplicate of bug 754767
Comment 2 Jiri Klimes 2015-09-14 14:31:09 UTC
*** Bug 754767 has been marked as a duplicate of this bug. ***
Comment 3 Thomas Haller 2015-09-15 16:23:52 UTC
patch merged to master as http://cgit.freedesktop.org/NetworkManager/NetworkManager/commit/?id=88f0d646d5089dfc8df9b03750ade72e921803eb


But it breaks `make check -C libnm`... REOPEN
Comment 4 Thomas Haller 2015-09-16 10:33:52 UTC
(In reply to Thomas Haller from comment #3)
> patch merged to master as
> http://cgit.freedesktop.org/NetworkManager/NetworkManager/commit/
> ?id=88f0d646d5089dfc8df9b03750ade72e921803eb
> 
> 
> But it breaks `make check -C libnm`... REOPEN

reverted too:

http://cgit.freedesktop.org/NetworkManager/NetworkManager/commit/?id=0e5af7fa46c2363315eda0963c1826b8ca9d6a53
Comment 5 Lubomir Rintel 2015-09-26 06:55:17 UTC
Created attachment 312178 [details]
A new fix
Comment 6 Thomas Haller 2015-09-26 18:24:01 UTC
(In reply to Lubomir Rintel from comment #5)
> Created attachment 312178 [details]
> A new fix

make check -C libnm/

still fails here...
Comment 7 Lubomir Rintel 2015-09-28 19:30:28 UTC
Created attachment 312321 [details]
A new fix

(In reply to Thomas Haller from comment #6)
> (In reply to Lubomir Rintel from comment #5)
> > Created attachment 312178 [details]
> > A new fix
> 
> make check -C libnm/
> 
> still fails here...

Whoops, sorry.

Works now.
Comment 8 Thomas Haller 2015-10-03 16:40:47 UTC
The test passes now.

I wonder, returning CONTINUE from deferred_notify_cb() effectively means busy-waiting. I think you should return G_SOURCE_REMOVE and always clear the notify-id...
I just don't understand from the code, whether that would mean we miss a notification.
Comment 9 Lubomir Rintel 2015-10-05 16:12:48 UTC
Created attachment 312682 [details]
A fixed version of the fix for a fix

(In reply to Thomas Haller from comment #8)
> The test passes now.
> 
> I wonder, returning CONTINUE from deferred_notify_cb() effectively means
> busy-waiting. I think you should return G_SOURCE_REMOVE and always clear the
> notify-id...

Yes, you're right.

I assumed the main loop doesn't spin when there's only idle sources (which is why I owe you a beer). It was probably that the dbus response was really quick to run when I was looking so that it didn't look like a busy loop (if the nm-remote-settings' GetSettings call took a bit longer then the client would indeed busy-wait here).

> I just don't understand from the code, whether that would mean we miss a
> notification.

Yes, we'd miss a notification. Added a list of objects whose properties are pending notifications that should be emitted after the init. Can't see a cleaner solution.

At least the tests run, and I've confirmed it to fix the bug.
Comment 10 Thomas Haller 2015-10-05 17:03:44 UTC
Created attachment 312684 [details] [review]
fixup! libnm: avoid notifying for objects until they're async-inited

The item (waiter) has a strong reference to the waited-items.
But I would not take a strong reference in the other direction too.
Comment 11 Lubomir Rintel 2015-10-06 13:18:03 UTC
This problem has been fixed in the unstable development version. The fix will be available in the next major software release. You may need to upgrade your Linux distribution to obtain that newer version.