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

Always use GC_set_stackbottom on Windows #12186

Merged

Conversation

HertzDevil
Copy link
Contributor

@HertzDevil HertzDevil commented Jul 2, 2022

When the Boehm GC pushes all stacks during a collection cycle, with POSIX Threads it uses GC_stackbottom as the bottom of the main thread's stack, but on Windows, it always uses an internal per-thread handle's stack_base member. This member is updated by GC_set_stackbottom. This means it is insufficient to assign directly to LibGC.$stackbottom, because then the GC would incorrectly collect memory reachable only from the main fiber if a different fiber is running while a collection cycle starts.

This fix gets rid of the occasional Thread stack pointer ... out of range, pushing everything warnings, and should also make the select stress test pass.

@HertzDevil HertzDevil added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:concurrency topic:stdlib:runtime platform:windows Windows support based on the MSVC toolchain / Win32 API labels Jul 2, 2022
@straight-shoota straight-shoota added this to the 1.5.0 milestone Jul 3, 2022
@straight-shoota straight-shoota merged commit a9a5d2b into crystal-lang:master Jul 4, 2022
@HertzDevil HertzDevil deleted the bug/win32-gc-set_stackbottom branch July 4, 2022 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. platform:windows Windows support based on the MSVC toolchain / Win32 API topic:stdlib:concurrency topic:stdlib:runtime
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants