8000 Mild red zone bug. · Issue #11 · edubart/minicoro · GitHub
[go: up one dir, main page]

Skip to content

Mild red zone bug. #11

Open
Open

Description

@slembcke

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.

Activity

  1. edubart commented on Jun 11, 2022

    @edubart
    Owner

    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.

  2. slembcke commented on Jun 11, 2022

    @slembcke
    Author
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0