Skip to content
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
Closed

Unexpected segfault #832

davidhesselbom opened this issue Sep 26, 2014 · 2 comments
Milestone

Comments

@davidhesselbom
Copy link
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
Copy link
Contributor Author

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
Copy link
Collaborator

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants