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 646286 - Passing initialized field to base constructor segfaults
Passing initialized field to base constructor segfaults
Status: RESOLVED DUPLICATE of bug 567269
Product: vala
Classification: Core
Component: Code Generator
0.11.x
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2011-03-31 00:10 UTC by Jim Nelson
Modified: 2011-04-02 14:02 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Jim Nelson 2011-03-31 00:10:29 UTC
This might be a duplicate of (or related to) bug 567269.

In Vala 0.11.7, if I initialize a member variable in its declaration and pass it to the base constructor, the program will segfault:

class Foo : Object {
}

class Base : Object {
    private Foo f;
    
    public Base(Foo f) {
        this.f = f;
    }
}

class Child : Base {
    private Foo child_f = new Foo();
    
    public Child() {
        // segfault here
        base (child_f);
    }
}

void main() {
    Child c = new Child();
    c = null;
}

The segfault occurs because self is being deref'ed before being allocated in child_construct():

    Child * self = NULL;
    self = (Child*) base_construct (object_type, self->priv->child_f);
Comment 1 Jürg Billeter 2011-04-02 14:02:00 UTC
Yes, this is exactly the same as bug 567269, implicit 'this' access is equivalent to explicit 'this' access.

Thanks for the bug report. This particular bug has already been reported into our bug tracking system, but please feel free to report any further bugs you find.

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