Interfaces unsafely assume abstract functions are implemented
Submitted by Travis Reitter
Link to original bug (#638434)
Description
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.