Unexpected segfault #832

Closed
davidhesselbom opened this Issue Sep 26, 2014 · 2 comments

Projects

None yet

3 participants

@davidhesselbom
Contributor

This causes a segfault:

Foo: cover {
    pointer : Int*
    init: func {
        this pointer = gc_malloc(1024)
    }
    dispose: func {
        gc_free(this pointer)
    }
}

foo := Foo new()
foo dispose()

This does not...

Foo: cover {
    pointer : Int*
    init: func {
        this pointer = gc_malloc(1024)
        gc_free(this pointer)
    }
    dispose: func {
    }
}

foo := Foo new()
foo dispose()

And neither does this:

Foo: cover {
    pointer : Int*
    init: func {
        this pointer = gc_malloc(1024)
        this dispose()
    }
    dispose: func {
        gc_free(this pointer)
    }
}

foo := Foo new()

What's going on here?

@davidhesselbom
Contributor

Argh, I needed init: func@ {. I've made that mistake a few times now... Maybe a warning would be nice, I don't know.

@shamanas
Collaborator

A "modifying this in a by value cover call" would be nice, indeed

@fasterthanlime fasterthanlime modified the milestone: 0.9.10 Jul 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment