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 727923 - CRITICAL **: nm_secret_agent_register: assertion 'priv->registered == FALSE' failed
CRITICAL **: nm_secret_agent_register: assertion 'priv->registered == FALSE' ...
Status: RESOLVED FIXED
Product: NetworkManager
Classification: Platform
Component: nm-applet
0.9.x
Other Linux
: Normal normal
: ---
Assigned To: NetworkManager maintainer(s)
NetworkManager maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2014-04-09 21:49 UTC by Paul Menzel
Modified: 2014-08-29 11:48 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
[patch] fix register secret agent (2.41 KB, patch)
2014-08-24 14:11 UTC, Thomas Haller
reviewed Details | Review
[patch] NetworkManager/libnm-glib (1.71 KB, patch)
2014-08-24 14:29 UTC, Thomas Haller
committed Details | Review

Description Paul Menzel 2014-04-09 21:49:49 UTC
Using Debian Sid/unstable with package `network-manager-gnome` 0.9.8.8-5 [1], the following message is displayed on the console when starting the applet under the awesome WM.

    CRITICAL **: nm_secret_agent_register: assertion 'priv->registered == FALSE' failed

[1] http://metadata.ftp-master.debian.org/changelogs//main/n/network-manager-applet/network-manager-applet_0.9.8.8-5_changelog
Comment 1 Chris Bainbridge 2014-04-25 12:46:58 UTC
Same with Debian Jessie and XFCE.
Comment 2 Paul Menzel 2014-08-23 19:32:53 UTC
Chris, thank you for submitting it also to the Debian BTS. For the record, the bug report number is #745811 in the Debian BTS [1].

[1] https://bugs.debian.org/745811
Comment 3 Paul Menzel 2014-08-23 20:13:08 UTC
Sometimes this messages is not shown during start-up, so I wonder if this is a racing/timing problem. The messages is thrown in the following code.

$ more libnm-glib/nm-secret-agent.c
[…]
/**
 * nm_secret_agent_register:
 * @self: a #NMSecretAgent
 *
 * Registers the #NMSecretAgent with the NetworkManager secret manager,
 * indicating to NetworkManager that the agent is able to provide and save
 * secrets for connections on behalf of its user.  Registration is an
 * asynchronous operation and its success or failure is indicated via the
 * 'registration-result' signal.
 *
 * Returns: a new %TRUE if registration was successfully requested (this does
 * not mean registration itself was successful), %FALSE if registration was not
 * successfully requested.
 **/
gboolean
nm_secret_agent_register (NMSecretAgent *self)
{
	NMSecretAgentPrivate *priv;
	NMSecretAgentClass *class;

	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (NM_IS_SECRET_AGENT (self), FALSE);

	priv = NM_SECRET_AGENT_GET_PRIVATE (self);

	g_return_val_if_fail (priv->registered == FALSE, FALSE);
	g_return_val_if_fail (priv->reg_call == NULL, FALSE);
	g_return_val_if_fail (priv->bus != NULL, FALSE);
	g_return_val_if_fail (priv->manager_proxy != NULL, FALSE);
[…]

I wonder what NMSecretAgent is supposed to be in Xfce and awesome. Seahorse? I have no idea.
Comment 4 Paul Menzel 2014-08-23 20:30:16 UTC
Judging from the answer to a superuser.com question [1], nm-applet is supposed to be the secret agent.

[1] http://superuser.com/questions/305314/archlinux-networkmanager-not-asking-for-wifi-passphrase
Comment 5 Thomas Haller 2014-08-24 14:11:28 UTC
Created attachment 284343 [details] [review]
[patch] fix register secret agent

I think the problem is that nm-applet creates the NMSecretAgent instance without setting NM_SECRET_AGENT_AUTO_REGISTER to FALSE (TRUE is the default).

And later still calls nm_secret_agent_register(). It either should let it autoregister, or register explicitly.


Attach a patch for upstream master, but it applies similarly to nma-0-9-8 branch.
Comment 6 Thomas Haller 2014-08-24 14:29:32 UTC
Created attachment 284344 [details] [review]
[patch] NetworkManager/libnm-glib

I think this is also an issue in libnm-glib.

Attach patch for NetworkManager (master)
Comment 7 Paul Menzel 2014-08-24 20:19:33 UTC
Thomas, thanks a lot for looking into this and for providing patches. I won’t be able to test them next week. Hopefully Chris can give it a go.
Comment 8 Paul Menzel 2014-08-24 20:26:38 UTC
Review of attachment 284343 [details] [review]:

Besides one question this looks good.

The summary could be reworded a little (although I am no native speaker):

    applet: Ensure to create secret agent only once

or even shorter

    applet: Create secret agent only once

::: src/applet.c
@@ +3571,3 @@
 		                                      applet);
 		g_clear_object (&applet->shell_watcher);
+	} else if (!applet->agent) {

Should an else branch be added for safety? I do not see the whole code, so I have no idea if all cases are covered.
Comment 9 Paul Menzel 2014-08-24 20:28:54 UTC
Review of attachment 284344 [details] [review]:

Looks good.

    libnm: Auto-register only not yet registered agents
Comment 10 Dan Winship 2014-08-25 13:37:39 UTC
Comment on attachment 284343 [details] [review]
[patch] fix register secret agent

>Subject: [PATCH 1/2] applet: ensure creating secret agent only once

this one is good

>Subject: [PATCH 2/2] applet: create AppletAgent without auto-register

but this is not; auto-register controls two different behaviors (whether the agent registers itself at startup, and whether it automatically re-registers itself if NetworkManager restarts). If you set it to FALSE, you lose both of these.

NMSecretAgent's semantics are confusing and broken, and it's on my to-do list to fix them in libnm...
Comment 11 Dan Winship 2014-08-25 13:38:38 UTC
Comment on attachment 284344 [details] [review]
[patch] NetworkManager/libnm-glib

This seems right though. Is this enough to fix the nm-applet problem even without the second part of the previous patch?
Comment 12 Thomas Haller 2014-08-25 13:47:11 UTC
(In reply to comment #11)
> (From update of attachment 284344 [details] [review])
> This seems right though. Is this enough to fix the nm-applet problem even
> without the second part of the previous patch?

I think this alone should fix the issue, but I couldn't reproduce it so I am not sure.


(In reply to comment #10)
> (From update of attachment 284343 [details] [review])
> >Subject: [PATCH 1 [details]/2] applet: ensure creating secret agent only once
>
> but this is not; auto-register controls two different behaviors (whether the
> agent registers itself at startup, and whether it automatically re-registers
> itself if NetworkManager restarts). If you set it to FALSE, you lose both of
> these.
> 
> NMSecretAgent's semantics are confusing and broken, and it's on my to-do list
> to fix them in libnm...

so, if not disabling auto-register, the proper fix in nm-applet seems just not (explicitly) call nm_secret_agent_register() and rely on auto-register.
Comment 13 Paul Menzel 2014-08-26 07:07:14 UTC
Thomas, just for my understanding, does your analysis match with the observation that this message is sometimes not shown?
Comment 14 Thomas Haller 2014-08-26 09:27:35 UTC
(In reply to comment #13)
> Thomas, just for my understanding, does your analysis match with the
> observation that this message is sometimes not shown?

Hi Paul,

I could not reproduce this, I just looked at the code and guess the cause. I did not see this error message.
Comment 15 Dan Winship 2014-08-26 19:08:54 UTC
(In reply to comment #13)
> Thomas, just for my understanding, does your analysis match with the
> observation that this message is sometimes not shown?

Yes, it would be a race condition.

I think the fix is clearly correct even if it doesn't fix Paul's bug (and likewise the applet "only register once" patch), so I'd say commit them.
Comment 17 Thomas Haller 2014-08-27 07:45:23 UTC
(In reply to comment #15)
> (In reply to comment #13)
> > Thomas, just for my understanding, does your analysis match with the
> > observation that this message is sometimes not shown?
> 
> Yes, it would be a race condition.
> 
> I think the fix is clearly correct even if it doesn't fix Paul's bug (and
> likewise the applet "only register once" patch), so I'd say commit them.

Dan, before you said:

(In reply to comment #10)
> >Subject: [PATCH 2 [details]/2] applet: create AppletAgent without auto-register
> 
> but this is not; auto-register controls two different behaviors (whether the
> agent registers itself at startup, and whether it automatically re-registers
> itself if NetworkManager restarts). If you set it to FALSE, you lose both of
> these.

so, I guess patch 2 is wrong, right? How about instead removing the nm_secret_agent_register() call?
Comment 18 Dan Winship 2014-08-27 13:10:08 UTC
not sure... I haven't looked at the code in a long time; there might be some case where it's needed
Comment 19 Thomas Haller 2014-08-27 16:08:21 UTC
Pushed first commit of attachment 284344 [details] [review]

master: https://git.gnome.org/browse/network-manager-applet/commit/?id=1731d6db5176f17f88fdcc48f99916101b8a12ae

nma-0-9-10: https://git.gnome.org/browse/network-manager-applet/commit/?id=4eb5e579ccb44d8e9edac82d0e896d921bb68486

(@Paul: I reworded the bug subject line)





Remaining issue is:


either in applet_agent_new() set the property:
  NM_SECRET_AGENT_AUTO_REGISTER, FALSE,

or in register_agent() remove:
  nm_secret_agent_register (NM_SECRET_AGENT (applet->agent));
Comment 20 Dan Williams 2014-08-27 18:57:38 UTC
(In reply to comment #19)
> Remaining issue is:
> 
> 
> either in applet_agent_new() set the property:
>   NM_SECRET_AGENT_AUTO_REGISTER, FALSE,
> 
> or in register_agent() remove:
>   nm_secret_agent_register (NM_SECRET_AGENT (applet->agent));

Let's just remove the nm_secret_agent_register().
Comment 21 Thomas Haller 2014-08-29 11:48:41 UTC
(In reply to comment #20)
> (In reply to comment #19)
> > Remaining issue is:
> > 
> > 
> > either in applet_agent_new() set the property:
> >   NM_SECRET_AGENT_AUTO_REGISTER, FALSE,
> > 
> > or in register_agent() remove:
> >   nm_secret_agent_register (NM_SECRET_AGENT (applet->agent));
> 
> Let's just remove the nm_secret_agent_register().

Done.


master: https://git.gnome.org/browse/network-manager-applet/commit/?id=d540a4e56589c1c6e6ba0bbe7558b1f7734c9879
nma-0-9-10: https://git.gnome.org/browse/network-manager-applet/commit/?id=b8cb2c5c9763e134c6ff9d6d8d273fca09e79b7d
nma-0-9-8: https://git.gnome.org/browse/network-manager-applet/commit/?id=40d6df069862216ed9985cf922f57d3af84c44d7