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

Cannot destroy a fiber that did not return #258

Open
vtereshkov opened this issue Dec 18, 2022 · 0 comments
Open

Cannot destroy a fiber that did not return #258

vtereshkov opened this issue Dec 18, 2022 · 0 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@vtereshkov
Copy link
Owner

vtereshkov commented Dec 18, 2022

Fibers are unable to free the allocated heap if their functions did not return in a regular way. This caused memory leaks, such as #16 and #255. To make the behavior more predictable and easier to analyze, any attempt to free a fiber variable whose function did not return is now treated as an error:

fn foo(parent: fiber, ctx: ^int) {
        a := make([]int, 10000)
        fibercall(parent)
}

fn main() {
        for i := 0; i < 10000; i++ {
                ctx := new(int)
                fibercall(fiberspawn(foo, ctx))
        }                                        // Runtime error: Cannot destroy a fiber that did not return
}

It is, however, very inconvenient for the user to care about how to terminate every fiber properly.

@vtereshkov vtereshkov added the enhancement New feature or request label Dec 18, 2022
@vtereshkov vtereshkov added the bug Something isn't working label Feb 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant