GNOME Bugzilla – Bug 621021
Crashes when using Soup
Last modified: 2010-06-09 13:39:33 UTC
Created attachment 163100 [details] test case I believe there might be a problem with memory management somewhere. I am using gobject introspection 0.6.14, and libsoup 2.30.1 from Debian. The program I am attaching crashes some times, when quitting. I am actually trying to figure out a crash I'm getting in a more complex application, I believe this might be related. Any ideas on how to get useful debugging information for this are welcomed!
This usually has to do with incorrect transfer annotations on the API you are using. I'm guessing message.get_uri() isn't marked as (transfer none) and the results are being freed. You can debug this by running the app in gdb as such: gdb --args python test.py When the crash occurs you can go up the stack and find which object is causing the crash. Another this is there is known issues with importing gtk and pygi in the same program. Try from gi.repository import Gtk instead (same for GObject). Also, pygobject needs to be compiled with the --enable-pygi switch.
Looking at git soup_message_get_uri is indeed annotated incorrectly: /** * soup_message_get_uri: * @msg: a #SoupMessage * * Gets @msg's URI * * Return value: the URI @msg is targeted for. **/ SoupURI * soup_message_get_uri (SoupMessage *msg) { g_return_val_if_fail (SOUP_IS_MESSAGE (msg), NULL); return SOUP_MESSAGE_GET_PRIVATE (msg)->uri; } If you notice we are simply returning an internal uri without reffing it. In this case the return value needs to be annotated as transfer none in the doc string: * Return value: (transfer none): the URI @msg is targeted for. There might be other API that needs the same treatment. Moving this to libsoup for now. If all the annotations are fixed and you still have an issue please feel free to switch this back to pygi.
fixed soup_message_get_uri() and a handful of other getters in git. (that's assuming you're using introspection from libsoup itself; I haven't kept the annotations in gir-repository up-to-date...) I think the guy who did most of the introspection work for libsoup was mostly using the server-side API, so you may find other places where the client-side API is missing annotations, etc.