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 793549 - Crash when using private object members in GObject-style constructor before object is constructed
Crash when using private object members in GObject-style constructor before o...
Status: RESOLVED DUPLICATE of bug 567269
Product: vala
Classification: Core
Component: Objects
0.40.x
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2018-02-17 21:29 UTC by Michael Catanzaro
Modified: 2018-02-17 21:39 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Michael Catanzaro 2018-02-17 21:29:15 UTC
This dumb code segfaults at runtime:


class Dumb : Object
{
    int a;

    public Dumb(int a)
    {
        this.a = a;

        Object();
    }

    public static void main()
    {
        new Dumb(2);
    }
}


this doesn't exist before Object() is called in the constructor. Should probably trigger a compiler error instead of a crash at runtime.
Comment 1 Michael Catanzaro 2018-02-17 21:30:42 UTC
The generated code (valac 0.38.7) looks like this:

Dumb* dumb_construct (GType object_type, gint a) {
	Dumb * self = NULL;
	gint _tmp0_;
	_tmp0_ = a;
	self->priv->a = _tmp0_; // <-- bad! too soon!
	self = (Dumb*) g_object_new (object_type, NULL);
	return self;
}
Comment 2 Rico Tzschichholz 2018-02-17 21:39:44 UTC

*** This bug has been marked as a duplicate of bug 567269 ***