Bug 98529 - invalid reference transfer on online account authentication
Summary: invalid reference transfer on online account authentication
Alias: None
Product: SyncEvolution
Classification: Unclassified
Component: SyncEvolution (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: SyncEvolution Community
QA Contact:
Depends on:
Reported: 2016-11-01 12:35 UTC by renato filho
Modified: 2016-11-03 10:07 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Description renato filho 2016-11-01 12:35:15 UTC
authentication process is leaking reference during the authentication:

This happens in all logs. Perhaps this is wrong:
GVariantCXX sessionData(ag_auth_data_get_login_parameters(m_authData,
extraOptions), TRANSFER_REF);

According to
ag_auth_data_get_login_parameters() does not transfer ownership, so
the line above probably should be:
GVariantCXX sessionData(g_variant_ref_sink(ag_auth_data_get_login_parameters(m_authData,
extraOptions)), TRANSFER_REF);

Not sure whether that has been broken all along or is due to an API
change. Alberto Mardegan wrote that code in SyncEvolution.

I see a commit which cleans up reference counting in libaccounts.
Perhaps the warning was not seen when writing the count because
ag_auth_data_get_login_parameters returned a GVariant where the ref
count already was too high, so decrementing once too often did no harm.
Comment 1 Patrick Ohly 2016-11-03 10:07:29 UTC
Fix included in master branch:

commit 59372771027ea98f59e42b2390263b077a71876c
Author: Patrick Ohly <patrick.ohly@intel.com>
Date:   Thu Nov 3 00:50:26 2016 -0700

    SignonAuthProvider: fix ref counting issue
    The account data was unreferenced once too often, or rather, a suitable ref
    count increase was missing. A debug build of glib detects that ("GLib:
    g_variant_unref: assertion 'value->ref_count > 0' failed"), but without that
    check the code might also crash.

diff --git a/src/backends/signon/signon-accounts.cpp b/src/backends/signon/signon-accounts.cpp
index 488a0e6..3ea9074 100644
--- a/src/backends/signon/signon-accounts.cpp
+++ b/src/backends/signon/signon-accounts.cpp
@@ -165,7 +165,7 @@ private:
         // so we have to use the "steal" variant to enable that assignment.
         GVariantStealCXX resultData;
         GErrorCXX gerror;
-        GVariantCXX sessionData(ag_auth_data_get_login_parameters(m_authData, extraOptions), TRANSFER_REF);
+        GVariantCXX sessionData(g_variant_ref_sink(ag_auth_data_get_login_parameters(m_authData, extraOptions)), TRANSFER_REF);
         const char *mechanism = ag_auth_data_get_mechanism(m_authData);
         PlainGStr buffer(g_variant_print(sessionData, true));
         SE_LOG_DEBUG(NULL, "asking for authentication with method %s, mechanism %s and parameters %s",

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.