New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected segfault #832

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

Comments

Projects
None yet
3 participants
@davidhesselbom
Contributor

davidhesselbom commented Sep 26, 2014

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

This comment has been minimized.

Contributor

davidhesselbom commented Sep 26, 2014

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

@alexnask

This comment has been minimized.

Collaborator

alexnask commented Sep 26, 2014

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment