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 688375 - Crash when trying to override GInterface method
Crash when trying to override GInterface method
Status: RESOLVED FIXED
Product: gobject-introspection
Classification: Platform
Component: general
unspecified
Other Linux
: Normal major
: ---
Assigned To: gobject-introspection Maintainer(s)
gobject-introspection Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2012-11-15 09:27 UTC by Guillaume Desmottes
Modified: 2015-02-07 16:50 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test script (196 bytes, application/javascript)
2012-11-15 09:27 UTC, Guillaume Desmottes
  Details
Guillaume's test case, with the missing “Implements: [ Clutter.Container ]” added (233 bytes, application/javascript)
2013-10-12 09:57 UTC, Will Thompson
  Details
GIVFuncInfo: allow retrieving the address of an interface vfunc (2.70 KB, patch)
2013-10-13 00:04 UTC, Giovanni Campagna
needs-work Details | Review
GIVFuncInfo: allow retrieving the address of an interface vfunc (2.69 KB, patch)
2013-10-21 19:34 UTC, Giovanni Campagna
committed Details | Review

Description Guillaume Desmottes 2012-11-15 09:27:45 UTC
Created attachment 229029 [details]
test script

See the attached example crashing when trying to override ClutterContainerIface->actor_removed.

  • #0 g_struct_info_get_n_fields
    at girepository/gistructinfo.c line 60
  • #1 g_vfunc_info_get_address
    at girepository/givfuncinfo.c line 229
  • #2 is_vfunc_unchanged
    at gi/object.c line 335
  • #3 object_instance_new_resolve
    at gi/object.c line 525
  • #4 CallResolveOp
  • #5 js_LookupPropertyWithFlagsInline
    at jsobj.cpp line 4971
  • #6 js_LookupProperty
    at jsobj.cpp line 5024
  • #7 js_HasOwnProperty
    at jsobj.cpp line 1472
  • #8 DefinePropertyOnObject
    at jsobj.cpp line 2073
  • #9 DefineProperty
    at jsobj.cpp line 2462
  • #10 DefineProperties
    at jsobj.cpp line 2526
  • #11 obj_defineProperties
    at jsobj.cpp line 2560
  • #12 CallJSNative
    at jscntxtinlines.h line 701
  • #13 js::Interpret
    at jsinterp.cpp line 4799
  • #14 js::RunScript
    at jsinterp.cpp line 653
  • #15 js::Invoke
    at jsinterp.cpp line 740
  • #16 js_fun_apply
    at jsfun.cpp line 2205
  • #17 CallJSNative
    at jscntxtinlines.h line 701
  • #18 js::Interpret
    at jsinterp.cpp line 4799
  • #19 js::RunScript
    at jsinterp.cpp line 653
  • #20 js::Invoke
    at jsinterp.cpp line 740
  • #21 js_fun_apply
    at jsfun.cpp line 2205
  • #22 CallJSNative
    at jscntxtinlines.h line 701
  • #23 js::Interpret
    at jsinterp.cpp line 4799
  • #24 js::RunScript
    at jsinterp.cpp line 653
  • #25 js::Invoke
    at jsinterp.cpp line 740
  • #26 js_fun_apply
    at jsfun.cpp line 2205
  • #27 CallJSNative
    at jscntxtinlines.h line 701
  • #28 js::Interpret
    at jsinterp.cpp line 4799
  • #29 js::RunScript
    at jsinterp.cpp line 653
  • #30 js::Invoke
    at jsinterp.cpp line 740
  • #31 js_fun_apply
    at jsfun.cpp line 2205
  • #32 CallJSNative
    at jscntxtinlines.h line 701
  • #33 js::Interpret
    at jsinterp.cpp line 4799
  • #34 js::RunScript
    at jsinterp.cpp line 653
  • #35 js::Invoke
    at jsinterp.cpp line 740
  • #36 js_fun_apply
    at jsfun.cpp line 2205
  • #37 CallJSNative
    at jscntxtinlines.h line 701
  • #38 js::Interpret
    at jsinterp.cpp line 4799
  • #39 js::RunScript
    at jsinterp.cpp line 653
  • #40 js::Invoke
    at jsinterp.cpp line 740
  • #41 js::InvokeConstructor
    at jsinterp.cpp line 1259
  • #42 js::CallOrConstructBoundFunction
    at jsfun.cpp line 2319
  • #43 CallJSNative
    at jscntxtinlines.h line 701
  • #44 CallJSNativeConstructor
    at jscntxtinlines.h line 720
  • #45 js::InvokeConstructor
    at jsinterp.cpp line 1244
  • #46 js::Interpret
    at jsinterp.cpp line 4686
  • #47 js::RunScript
    at jsinterp.cpp line 653
  • #48 js::Execute
    at jsinterp.cpp line 1028
  • #49 EvaluateUCScriptForPrincipalsCommon
    at jsapi.cpp line 5031
  • #50 JS_EvaluateUCScriptForPrincipals
    at jsapi.cpp line 5058
  • #51 JS_EvaluateUCScript
    at jsapi.cpp line 5066
  • #52 gjs_context_eval
  • #53 main
    at gjs/console.c line 110

Comment 1 Giovanni Campagna 2012-12-02 23:00:31 UTC
While we should not crash in this case, the problem is that you're not implementing Clutter.Container.
Comment 2 Guillaume Desmottes 2012-12-03 15:47:05 UTC
How so? ClutterContainer is implemented by ClutterActor from which my object inherit.
Comment 3 Giovanni Campagna 2012-12-10 23:01:59 UTC
Yes, but in GObject, if you want to override an interface method, you need to implement the interface again.

Think of how you would do it in C: you would call G_IMPLEMENT_INTERFACE, and then override the interface method inside the iface_init(). You can't do the override from class_init(), or anywhere else.
Comment 4 Will Thompson 2013-10-12 09:55:35 UTC
(In reply to comment #1)
> While we should not crash in this case, the problem is that you're not
> implementing Clutter.Container.

Nope, it crashes in exactly the same way if I add:

  Implements: [ Clutter.Container ],

to Guillaume's example.
Comment 5 Will Thompson 2013-10-12 09:57:41 UTC
Created attachment 257093 [details]
Guillaume's test case, with the missing “Implements: [ Clutter.Container ]” added
Comment 6 Giovanni Campagna 2013-10-13 00:04:31 UTC
Created attachment 257134 [details] [review]
GIVFuncInfo: allow retrieving the address of an interface vfunc

Don't assume that the parent of a GIVFuncInfo is a GIObjectInfo,
it could be a GIInterfaceInfo, if the vfunc is part of interface
instead of a class.
Comment 7 Jasper St. Pierre (not reading bugmail) 2013-10-13 14:20:30 UTC
Review of attachment 257134 [details] [review]:

::: girepository/givfuncinfo.c
@@ -255,3 @@
   func = *(gpointer*) G_STRUCT_MEMBER_P (implementor_vtable, offset);
-  g_type_class_unref (implementor_vtable);
-  g_base_info_unref (field_info);

Memory leak? Why was this removed?
Comment 8 Giovanni Campagna 2013-10-21 19:34:18 UTC
Created attachment 257789 [details] [review]
GIVFuncInfo: allow retrieving the address of an interface vfunc

Don't assume that the parent of a GIVFuncInfo is a GIObjectInfo,
it could be a GIInterfaceInfo, if the vfunc is part of interface
instead of a class.
Comment 9 Colin Walters 2013-10-22 21:18:22 UTC
Review of attachment 257789 [details] [review]:

Ok, makes sense.
Comment 10 Giovanni Campagna 2013-10-22 21:34:07 UTC
Attachment 257789 [details] pushed as f7acdd3 - GIVFuncInfo: allow retrieving the address of an interface vfunc
Comment 11 André Klapper 2015-02-07 16:50:12 UTC
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]