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 681565 - Problem with GParamSpec return values: g_object_get_qdata() called on param spec
Problem with GParamSpec return values: g_object_get_qdata() called on param spec
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: introspection
Git master
Other Linux
: Normal blocker
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2012-08-09 22:35 UTC by Mathieu Duponchelle
Modified: 2012-08-20 20:56 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
This patch allows a discrimination between GObject and GParamSpecs (1.14 KB, patch)
2012-08-15 21:25 UTC, Mathieu Duponchelle
reviewed Details | Review
Updates test_gi.py (481 bytes, patch)
2012-08-20 20:29 UTC, Mathieu Duponchelle
none Details | Review
Updates gimarshallingtests (1.08 KB, patch)
2012-08-20 20:30 UTC, Mathieu Duponchelle
none Details | Review

Description Mathieu Duponchelle 2012-08-09 22:35:25 UTC
Hi !
We have this function : http://fpaste.org/CPaG/
which gives an incorrect pointer for the GParamSpec. I couldn't find working examples for how to return such types, and I think the annotations are correct. I tried to set the transfer type to floating but no luck either.

example output :

Correct values :
ges ges-track-object.c:1176:ges_track_object_lookup_child: pspec : 0x2c66800 elem : 0x11d5400

returned tuple in python:
(True, <__main__.GstAgingTV object at 0x18dcf00 (GstAgingTV at 0x11d5400)>, <gi.repository.GObject.ParamSpecUInt object at 0x2279810>)
Comment 1 Tim-Philipp Müller 2012-08-12 11:39:23 UTC
I made a little test program that calls gst_child_proxy_lookup(), which has a GParamSpec as one of the out arguments:

It fails with:

/usr/lib/python2.7/dist-packages/gi/types.py:43: Warning: g_object_get_qdata: assertion `G_IS_OBJECT (object)' failed
  return info.invoke(*args, **kwargs)
/usr/lib/python2.7/dist-packages/gi/types.py:43: Warning: g_object_ref_sink: assertion `G_IS_OBJECT (object)' failed
  return info.invoke(*args, **kwargs)

** (python:27838): CRITICAL **: pygobject_register_wrapper: assertion `PyObject_TypeCheck(self, &PyGObject_Type)' failed
(True, <__main__.GstPlayBin object at 0x7fccaa45b460 (GstPlayBin at 0x1bbe680)>, <gi.repository.GObject.ParamSpecObject object at 0x7fcca9ffdfd0>)


Stack trace:

tpm@zingle:~/gst/0.11/gstreamer$ G_DEBUG=fatal_warnings gdb --args python ../lookup-pspec.py
(gdb) run
Starting program: /usr/bin/python ../lookup-pspec.py

(python:27852): GLib-GObject-CRITICAL **: g_object_get_qdata: assertion `G_IS_OBJECT (object)' failed

Program received signal SIGTRAP, Trace/breakpoint trap.
g_logv (log_domain=0x7ffff6323f6c "GLib-GObject", log_level=G_LOG_LEVEL_CRITICAL, format=0x7ffff586a6e2 "%s: assertion `%s' failed", args1=args1@entry=0x7fffffffbc78) at /tmp/buildd/glib2.0-2.32.3/./glib/gmessages.h:101
101	/tmp/buildd/glib2.0-2.32.3/./glib/gmessages.h: No such file or directory.
(gdb) bt
  • #0 g_logv
    at /tmp/buildd/glib2.0-2.32.3/./glib/gmessages.h line 101
  • #1 g_log
    at /tmp/buildd/glib2.0-2.32.3/./glib/gmessages.c line 792
  • #2 g_return_if_fail_warning
  • #3 g_object_get_qdata
    at /tmp/buildd/glib2.0-2.32.3/./gobject/gobject.c line 3088
  • #4 ??
    from /usr/lib/python2.7/dist-packages/gi/_gobject/_gobject.so
  • #5 ??
    from /usr/lib/python2.7/dist-packages/gi/_gi.so
  • #6 ??
    from /usr/lib/python2.7/dist-packages/gi/_gi.so
  • #7 ext_do_call
    at ../Python/ceval.c line 4331
  • #8 PyEval_EvalFrameEx
  • #9 PyEval_EvalCodeEx
  • #10 fast_function
    at ../Python/ceval.c line 4117
  • #11 call_function
    at ../Python/ceval.c line 4042
  • #12 PyEval_EvalFrameEx
  • #13 PyEval_EvalCodeEx
  • #14 PyEval_EvalCode
  • #15 run_mod
  • #16 PyRun_FileExFlags
  • #17 PyRun_SimpleFileExFlags
    at ../Python/pythonrun.c line 943
  • #18 PyRun_AnyFileExFlags
    at ../Python/pythonrun.c line 747
  • #19 Py_Main
    at ../Modules/main.c line 639
  • #20 __libc_start_main
    at libc-start.c line 228
  • #21 _start




It looks like it tries to call g_object_get_qdata() on a GParamSpec, which is not a GObject:


(gdb) print *object
$1 = {g_type_instance = {g_class = 0x9a7b50}, ref_count = 4092817894, qdata = 0xe1}
(gdb) print *((GParamSpec*)object)
$2 = {g_type_instance = {g_class = 0x9a7b50}, name = 0x7ffff3f371e6 "source", flags = 225, value_type = 10409216, owner_type = 12622624, _nick = 0x7ffff3f36c6e "Source", _blurb = 0x7ffff3f380c6 "Source element", qdata = 0x0, 
  ref_count = 2, param_id = 5}
Comment 2 Tim-Philipp Müller 2012-08-12 12:40:56 UTC
Apologies, that trace was missing the most interesting bits since I didn't have debug symbols for pygobject/pygi installed.

Here are the interesting bits then:

  • #3 g_object_get_qdata
    at /tmp/buildd/glib2.0-2.32.3/./gobject/gobject.c line 3088
  • #4 pygobject_new_full
    at /home/martin/debian/pkg-gnome/build-area/pygobject-3.2.2/gi/_gobject/pygobject.c line 914
  • #5 _pygi_marshal_to_py_interface_object
    at /home/martin/debian/pkg-gnome/build-area/pygobject-3.2.2/gi/pygi-marshal-to-py.c line 795
  • #6 _invoke_marshal_out_args
    at /home/martin/debian/pkg-gnome/build-area/pygobject-3.2.2/gi/pygi-invoke.c line 590
  • #7 _wrap_g_callable_info_invoke
    at /home/martin/debian/pkg-gnome/build-area/pygobject-3.2.2/gi/pygi-invoke.c line 638
  • #8 ext_do_call
    at ../Python/ceval.c line 4331
 
Looking at the code in git master, this issue most likely still exists.

_pygi_marshal_to_py_interface_object() calls pygobject_new() for the GParamSpec, and pygobject_new() assumes the passed pointer is a GObject.

Not sure what the correct fix is - checking with G_IS_PARAM_SPEC and using pyg_param_spec_new() instead ? Would changes in other places be required too?
Comment 3 Mathieu Duponchelle 2012-08-12 12:44:00 UTC
Thanks a lot for taking a look, that problem really is a blocker for us. I hope we can find a solution this week !
Comment 4 Mathieu Duponchelle 2012-08-15 21:25:23 UTC
Created attachment 221319 [details] [review]
This patch allows a discrimination between GObject and GParamSpecs

I don't know if other types would need to be recognized as well ?
Comment 5 Martin Pitt 2012-08-20 15:24:09 UTC
Comment on attachment 221319 [details] [review]
This patch allows a discrimination between GObject and GParamSpecs

Thanks for this! Patch looks fine, but I'd feel better with adding an API to GIMarshallingTests and adding a test case for this.
Comment 6 Mathieu Duponchelle 2012-08-20 20:29:36 UTC
Created attachment 221893 [details] [review]
Updates test_gi.py
Comment 7 Mathieu Duponchelle 2012-08-20 20:30:25 UTC
Created attachment 221894 [details] [review]
Updates gimarshallingtests
Comment 8 Martin Pitt 2012-08-20 20:56:54 UTC
g-i test case cleaned up, and added an (out) variant as well:

http://git.gnome.org/browse/gobject-introspection/commit/?id=4aed22c74b1

Finished pygobject test cases, and committed together with the patch:

http://git.gnome.org/browse/pygobject/commit/?id=5cd18c9bd59

Thanks!