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 638434 - Interfaces unsafely assume abstract functions are implemented
Interfaces unsafely assume abstract functions are implemented
Status: RESOLVED OBSOLETE
Product: vala
Classification: Core
Component: Code Generator: GObject
unspecified
Other Linux
: Normal normal
: 1.0
Assigned To: Vala maintainers
Vala maintainers
: 779887 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2010-12-31 23:10 UTC by Travis Reitter
Modified: 2018-05-22 13:50 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Travis Reitter 2010-12-31 23:10:31 UTC
valac generates interface virtual function wrappers like the following:

properties
----------
gint interface_get_foo (FolksExtendedInfo* self) {
  return INTERFACE_GET_INTERFACE (self)->get_foo (self);
}

void interface_set_foo (FolksExtendedInfo* self, gint value) {
  INTERFACE_GET_INTERFACE (self)->set_foo (self, value);
}

methods
-------
gint interface_bar (Interface* self) {
  return INTERFACE_GET_INTERFACE (self)->bar (self);
}

If 'foo' is a property or bar() is a method added to the interface after an implementing class implements the interface, accessing the property or calling the method on the old class will cause a segfault and otherwise put the client program in a very bad state.

This situation can easily happen if a library exposes an interface which is implemented by a third-party library (which won't necessarily be up-to-date with the latest interface version), breaking backward compatibility in a very fragile way.
Comment 1 Luca Bruno 2011-01-04 08:28:52 UTC
You can use abstract instead of virtual.
Comment 2 Travis Reitter 2011-01-04 16:42:41 UTC
(In reply to comment #1)
> You can use abstract instead of virtual.

Sorry, the functions are literally 'abstract' in Vala. I was referring to the C interface functions as 'virtual', since that's more common terminology in that context.

I'll update the bug title.
Comment 3 Rico Tzschichholz 2017-03-11 16:15:10 UTC
*** Bug 779887 has been marked as a duplicate of this bug. ***
Comment 4 Daniel Espinosa 2017-03-11 18:19:41 UTC
Using:

if (INTERFACE_GET_INTERFACE (self)->get_foo (self) != NULL)
    return INTERFACE_GET_INTERFACE (self)->get_foo (self);

return -1;

But this code should mutate based on return type.
Comment 5 Christian Hergert 2017-03-11 19:55:25 UTC
While bug 779887 might be a dup of this, the difference I was trying to explain is that the vfunc may not exist at all. So even doing ->get_foo is a source error in C.
Comment 6 GNOME Infrastructure Team 2018-05-22 13:50:24 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/153.