Skip to content

Commit

Permalink
Fix: disable crystal-lang/crystal#14558 patch
Browse files Browse the repository at this point in the history
It seems to be creating parallelism issues with the GC instead of fixing
them.
  • Loading branch information
ysbaddaden committed Oct 4, 2024
1 parent 4c84051 commit 1ff0c3a
Showing 1 changed file with 34 additions and 34 deletions.
68 changes: 34 additions & 34 deletions src/core_ext/thread.cr
Original file line number Diff line number Diff line change
Expand Up @@ -28,40 +28,40 @@ class Thread
# the following methods apply these patches:
# https://github.com/crystal-lang/crystal/pull/14558

def initialize(@name : String? = nil, &@func : Thread ->)
@system_handle = uninitialized Crystal::System::Thread::Handle
init_handle

Thread.threads.push(self) # <= moved here
end

protected def start
Thread.current = self
@current_fiber = @main_fiber = fiber = Fiber.new(stack_address, self)

if name = @name
self.system_name = name
end

begin
@func.call(self)
rescue ex
@exception = ex
ensure
{% if flag?(:preview_mt) %}
# fix the thread stack now so we can start cleaning up references
GC.lock_read
GC.set_stackbottom(self.gc_thread_handler, fiber.@stack_bottom)
GC.unlock_read
{% else %}
GC.set_stackbottom(fiber.@stack_bottom)
{% end %}

Thread.threads.delete(self)
Fiber.inactive(fiber)
detach { system_close }
end
end
# def initialize(@name : String? = nil, &@func : Thread ->)
# @system_handle = uninitialized Crystal::System::Thread::Handle
# init_handle

# Thread.threads.push(self) # <= moved here
# end

# protected def start
# Thread.current = self
# @current_fiber = @main_fiber = fiber = Fiber.new(stack_address, self)

# if name = @name
# self.system_name = name
# end

# begin
# @func.call(self)
# rescue ex
# @exception = ex
# ensure
# {% if flag?(:preview_mt) %}
# # fix the thread stack now so we can start cleaning up references
# GC.lock_read
# GC.set_stackbottom(self.gc_thread_handler, fiber.@stack_bottom)
# GC.unlock_read
# {% else %}
# GC.set_stackbottom(fiber.@stack_bottom)
# {% end %}

# Thread.threads.delete(self)
# Fiber.inactive(fiber)
# detach { system_close }
# end
# end

def scheduler : Crystal::Scheduler
raise "BUG: deprecated call to Thread#scheduler"
Expand Down

0 comments on commit 1ff0c3a

Please sign in to comment.