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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion spec/std/concurrent/select_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ describe "select" do
x.should eq 2
end

pending_win32 "stress select with send/receive in multiple fibers" do
it "stress select with send/receive in multiple fibers" do
fibers = 4
msg_per_sender = 1000
ch = Array.new(fibers) { Array.new(fibers) { Channel(Int32).new } }
Expand Down
14 changes: 12 additions & 2 deletions src/gc/boehm.cr
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ lib LibGC

fun push_all_eager = GC_push_all_eager(bottom : Void*, top : Void*)

{% if flag?(:preview_mt) %}
{% if flag?(:preview_mt) || flag?(:win32) %}
fun get_my_stackbottom = GC_get_my_stackbottom(sb : StackBase*) : ThreadHandle
fun set_stackbottom = GC_set_stackbottom(th : ThreadHandle, sb : StackBase*) : ThreadHandle
{% else %}
Expand Down Expand Up @@ -262,7 +262,7 @@ module GC

# :nodoc:
def self.current_thread_stack_bottom
{% if flag?(:preview_mt) %}
{% if flag?(:preview_mt) || flag?(:win32) %}
th = LibGC.get_my_stackbottom(out sb)
{th, sb.mem_base}
{% else %}
Expand All @@ -277,6 +277,16 @@ module GC
sb.mem_base = stack_bottom
LibGC.set_stackbottom(thread_handle, pointerof(sb))
end
{% elsif flag?(:win32) %}
# this is necessary because Boehm GC does _not_ use `GC_stackbottom` on
# Windows when pushing all threads' stacks; instead `GC_set_stackbottom`
# must be used to associate the new bottom with the running thread
def self.set_stackbottom(stack_bottom : Void*)
sb = LibGC::StackBase.new
sb.mem_base = stack_bottom
# `nil` represents the current thread (i.e. the only one)
LibGC.set_stackbottom(nil, pointerof(sb))
end
{% else %}
def self.set_stackbottom(stack_bottom : Void*)
LibGC.stackbottom = stack_bottom
Expand Down