diff --git a/spec/std/concurrent/select_spec.cr b/spec/std/concurrent/select_spec.cr index 55794ad3b050..781bf6a0a46b 100644 --- a/spec/std/concurrent/select_spec.cr +++ b/spec/std/concurrent/select_spec.cr @@ -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 } } diff --git a/src/gc/boehm.cr b/src/gc/boehm.cr index f289741622d0..2a76eb950a4b 100644 --- a/src/gc/boehm.cr +++ b/src/gc/boehm.cr @@ -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 %} @@ -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 %} @@ -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