Skip to content

Commit

Permalink
tasks: Don't make parent sticky in finalizer (#48919)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpsamaroo authored Mar 13, 2023
1 parent 441c570 commit 9f997fc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion base/condition.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function _wait2(c::GenericCondition, waiter::Task, first::Bool=false)
push!(c.waitq, waiter)
end
# since _wait2 is similar to schedule, we should observe the sticky bit now
if waiter.sticky && Threads.threadid(waiter) == 0
if waiter.sticky && Threads.threadid(waiter) == 0 && !GC.in_finalizer()
# Issue #41324
# t.sticky && tid == 0 is a task that needs to be co-scheduled with
# the parent task. If the parent (current_task) is not sticky we must
Expand Down
4 changes: 2 additions & 2 deletions base/task.jl
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ function _wait2(t::Task, waiter::Task)
unlock(t.donenotify)
# since _wait2 is similar to schedule, we should observe the sticky
# bit, even if we aren't calling `schedule` due to this early-return
if waiter.sticky && Threads.threadid(waiter) == 0
if waiter.sticky && Threads.threadid(waiter) == 0 && !GC.in_finalizer()
# Issue #41324
# t.sticky && tid == 0 is a task that needs to be co-scheduled with
# the parent task. If the parent (current_task) is not sticky we must
Expand Down Expand Up @@ -771,7 +771,7 @@ function enq_work(t::Task)
# Sticky tasks go into their thread's work queue.
if t.sticky
tid = Threads.threadid(t)
if tid == 0
if tid == 0 && !GC.in_finalizer()
# The task is not yet stuck to a thread. Stick it to the current
# thread and do the same to the parent task (the current task) so
# that the tasks are correctly co-scheduled (issue #41324).
Expand Down

0 comments on commit 9f997fc

Please sign in to comment.