Skip to content

Return None from remaining_stack when off the cached stack - #156

Open
stevecrozz wants to merge 2 commits into
rust-lang:masterfrom
stevecrozz:remaining-stack-foreign-stacks
Open

stevecrozz wants to merge 2 commits into
rust-lang:masterfrom
stevecrozz:remaining-stack-foreign-stacks

Conversation

@stevecrozz

Copy link
Copy Markdown

remaining_stack() subtracted the cached lowest address of the thread's stack from the stack pointer without checking that the stack pointer was on that stack. Hosts such as Ruby fibers and C coroutine libraries switch to stacks of their own, and there the result was 0 when the stack sat below the thread's stack, or more than the stack's whole size when it sat above it, which keeps maybe_grow from growing before an overflow.

Cache both ends of the stack and return None when the stack pointer is outside them. maybe_grow already grows when the remaining stack is unknown.

remaining_stack() subtracted the cached lowest address of the thread's
stack from the stack pointer without checking that the stack pointer was
on that stack. Hosts such as Ruby fibers and C coroutine libraries switch
to stacks of their own, and there the result was 0 when the stack sat
below the thread's stack, or more than the stack's whole size when it sat
above it, which keeps maybe_grow from growing before an overflow.

Cache both ends of the stack and return None when the stack pointer is
outside them. maybe_grow already grows when the remaining stack is
unknown.
psm::on_stack doesn't exist on Windows or under Miri, so the tests failed
to compile there.

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

1 participant