You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You subtract the 128 bytes from the size of the stack, and then use that size to find the high address of the stack. The red zone is the space with lower addresses than the current stack pointer, while your reserved space is above the start of the stack. Also, the red zone really only applies meaningfully to leaf functions so they can skip adjusting the stack pointer without getting stomped by interrupts. Any function that calls resume/yield is no longer a leaf function, so you don't have to worry about it in your implementation.
The text was updated successfully, but these errors were encountered:
You mean Win64 shadow space? That’s callee saved and applies on every function call, not the stack as a whole. You don’t need to worry about it unless calling a function IIRC. (On my phone at the moment) I also don’t remember SysV having something similar.
- Scott
On Jun 11, 2022, at 13:12, Eduardo Bart ***@***.***> wrote:
So this is not really a bug, just waste of stack space.
What about the x64 shadow space? At line
https://github.com/edubart/minicoro/blob/main/minicoro.h#L666
Maybe 128 bytes is a waste on Linux, but 32 bytes still required?
I am afraid of removing that line and causing bugs, I didn't study x86_64 ABI that well, so I reserved that space just to be safe.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.
Spotted a pretty mild bug related to red zones. The current code shouldn't cause any bugs. It just wastes a few bytes of stack space.
https://github.com/edubart/minicoro/blob/main/minicoro.h#L742
You subtract the 128 bytes from the size of the stack, and then use that size to find the high address of the stack. The red zone is the space with lower addresses than the current stack pointer, while your reserved space is above the start of the stack. Also, the red zone really only applies meaningfully to leaf functions so they can skip adjusting the stack pointer without getting stomped by interrupts. Any function that calls resume/yield is no longer a leaf function, so you don't have to worry about it in your implementation.
The text was updated successfully, but these errors were encountered: