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 738259 - GDBusInterfaceVTable: clarify memory handling for the method() virtual function
GDBusInterfaceVTable: clarify memory handling for the method() virtual function
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gdbus
unspecified
Other All
: Normal normal
: ---
Assigned To: David Zeuthen (not reading bugmail)
gtkdev
Depends on:
Blocks:
 
 
Reported: 2014-10-09 19:03 UTC by Owen Taylor
Modified: 2014-10-28 17:59 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GDBusInterfaceVTable: clarify memory handling for the method() virtual function (2.90 KB, patch)
2014-10-09 19:03 UTC, Owen Taylor
committed Details | Review

Description Owen Taylor 2014-10-09 19:03:01 UTC
There are two consistent interpretations that could be taken for memory
handling of the 'invocation' parameter passed to the method_call() virtual
function of GDBusInterfaceVTable

 - A reference is passed (transfer full) to the method_call() virtual function,
   and that reference is then passed (transfer full) to the return_value/error
   functions on GDBusMethodInvocation.
 - An internal reference is retained from the point where method_call() is called
   until the return_value/error function is called.

Since the return_value/error functions were already marked (transfer full),
we use the first interpretation, annotate the invocation parameter of
method call as (transfer full) and describe this in the documentation, along
with the idea that you are always supposed to call one of the return_value/error
functions.

See bug 738122 for the leak this caused in GJS.
Comment 1 Owen Taylor 2014-10-09 19:03:03 UTC
Created attachment 288168 [details] [review]
GDBusInterfaceVTable: clarify memory handling for the method() virtual function
Comment 2 Allison Karlitskaya (desrt) 2014-10-15 07:39:42 UTC
Review of attachment 288168 [details] [review]:

As much as I'd love to revert this nonsense, we're probably stuck at this point in time.

Thanks for the fix and clarification -- feel free to commit with the minor tweak mentioned.

::: gio/gdbusconnection.h
@@ +347,3 @@
+ * function is transferred to your handler; you must then call one of the
+ * methods of #GDBusMethodInvocation to return a reply (possibly empty),
+ * or an error. These functions also take ownership of the passed-

Maybe worth adding a mention that it's possible to do this some time after the method call has returned (ie: async handling).
Comment 3 Owen Taylor 2014-10-28 17:58:51 UTC
Pushed with some added language in the documentation that you can call the return function
immediately or later.

Attachment 288168 [details] pushed as 66fc112 - GDBusInterfaceVTable: clarify memory handling for the method() virtual function