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

Revise memory management for cancellation callbacks in runtime.Context. #1

Open
lithdew opened this issue Aug 22, 2021 · 1 comment

Comments

@lithdew
Copy link
Owner

lithdew commented Aug 22, 2021

A dirty hack that is being used right now is that runtime.Context stack-allocates a fixed-sized [1024]u8 to serve as the stack for the invocation of async cancellation callbacks.

For all the cancellation callbacks in Rheia so far, the hack works just fine. Though, it would be good to have the stacks of all async cancellation callbacks heap-allocated upon calling runtime.Context.register().

The alternative is to explicitly disallow async cancellation callbacks. The only cancellation callbacks that are async right now are the ones used to cancel pending I/O requests to io_uring. It might be plausible to make I/O cancellation not be async by having all requests to cancel some I/O request R queue R into a linked list which is flushed on every event loop tick iteration.

This issue is blocking the inclusion of 'context hierarchies' into Rheia, which is why all code in Rheia right now avoids creating child contexts that are canceled when a parent context is canceled (by registering a cancelation callback that calls child_context.cancel() to the parent context).

@lithdew
Copy link
Owner Author

lithdew commented Sep 2, 2021

Fixed in staging branch. Will close once the branch is merged.

The solution that was picked is to explicitly disallow async cancellation callbacks.

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

1 participant