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

Pages with no access to catch stack overflows? #19

Closed
ColinH opened this issue Feb 21, 2024 · 2 comments
Closed

Pages with no access to catch stack overflows? #19

ColinH opened this issue Feb 21, 2024 · 2 comments

Comments

@ColinH
Copy link

ColinH commented Feb 21, 2024

Would it be feasible to use a memory page with PROT_NONE at both the top and bottom of a coroutine stack to catch overflows immediately instead of after the fact in mco_yield()? I realise this would crash the application, hard, but that might be desirable for some use cases...

@edubart
Copy link
Owner

edubart commented Mar 21, 2024

Yes, you can already do this with a custom allocator, outside this library. Note that you can also use the MCO_USE_VMEM_ALLOCATOR (if your OS supports it) and have large stack for every coroutine without really making RAM usage high. If you have a big stack, stack overflows are unlikely to happen.

@ColinH
Copy link
Author

ColinH commented Mar 22, 2024

For the moment I hardwired a single PROT_NONE page at the bottom of the stack to reliably crash on stack overflow.

https://github.com/ColinH/mini-coro-plus/blob/87997010d62a50615505f2db8e9b4cbed3fff174/mini_coro_plus.ipp#L571

@ColinH ColinH closed this as completed Mar 22, 2024
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

2 participants