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 648897 - Redundant interface references confuse method resolution
Redundant interface references confuse method resolution
Status: RESOLVED OBSOLETE
Product: vala
Classification: Core
Component: Objects
unspecified
Other All
: Normal major
: ---
Assigned To: Vala maintainers
Vala maintainers
: 789443 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2011-04-28 20:16 UTC by Lucas Beeler
Modified: 2018-05-22 14:01 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Lucas Beeler 2011-04-28 20:16:07 UTC
This bug may be the result of Vala or the GObject/GType runtime system. The
crux of the problem is basically this:

(i) Define an interface:

public interface Doable : Object {
   public abstract int some_method(int input);
}

(ii) Define an abstract class that implements the interface, including
a concrete implementation of some_method( ):

public abstract class Gizmo : Object, Doable {
   public int some_method(int input) {
       return input + 1;
   }
}

(iii) Define a concrete class that extends Gizmo, but make it
redundantly require the Doable interface (this is redundant because
all Gizmos already are Doable)

public class Thingamajig : Gizmo, Doable {
   public char some_other_method() {
       return 'j';
   }
}

(iv) Now, attempt to call some_method() on a Thingamajig:

Thingamajig t = new Thingamajig();
int i = t.some_method(42);

This will cause a segfault. Moreover, if you look at the stack trace,
before the segfault you'll see a pattern of thousands of recursive
calls as the GObject runtime system attempts to resolve some_method( )
to an actual function pointer so that it can invoke it.

If you want to eliminate the segfault, you need only change the
definition of class Thingamajig to this:

public class Thingamajig : Gizmo {
   public char some_other_method() {
       return 'j';
   }
}

Note that the semantics of Thingamajig's definition are exactly what
they were before -- a Thingamajig is still Doable because its
superclass Gizmo is Doable. But we've removed the redundant reference
to Doable in the definition of Thingamajig. In this latter case, the
GObject runtime system has no problem resolving some_method( ), so we
get no segfault.
Comment 1 Rico Tzschichholz 2018-02-21 12:02:22 UTC
*** Bug 789443 has been marked as a duplicate of this bug. ***
Comment 2 GNOME Infrastructure Team 2018-05-22 14:01:40 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/vala/issues/196.