Skip to content

Commit dbd8802

Browse files
committed
tasks: Don't make parent sticky in finalizer
1 parent c811cf5 commit dbd8802

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

base/condition.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ function _wait2(c::GenericCondition, waiter::Task, first::Bool=false)
8787
push!(c.waitq, waiter)
8888
end
8989
# since _wait2 is similar to schedule, we should observe the sticky bit now
90-
if waiter.sticky && Threads.threadid(waiter) == 0
90+
if waiter.sticky && Threads.threadid(waiter) == 0 && !GC.in_finalizer()
9191
# Issue #41324
9292
# t.sticky && tid == 0 is a task that needs to be co-scheduled with
9393
# the parent task. If the parent (current_task) is not sticky we must

base/task.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ function _wait2(t::Task, waiter::Task)
323323
unlock(t.donenotify)
324324
# since _wait2 is similar to schedule, we should observe the sticky
325325
# bit, even if we aren't calling `schedule` due to this early-return
326-
if waiter.sticky && Threads.threadid(waiter) == 0
326+
if waiter.sticky && Threads.threadid(waiter) == 0 && !GC.in_finalizer()
327327
# Issue #41324
328328
# t.sticky && tid == 0 is a task that needs to be co-scheduled with
329329
# the parent task. If the parent (current_task) is not sticky we must
@@ -769,7 +769,7 @@ function enq_work(t::Task)
769769
(t._state === task_state_runnable && t.queue === nothing) || error("schedule: Task not runnable")
770770
if t.sticky || Threads.threadpoolsize() == 1
771771
tid = Threads.threadid(t)
772-
if tid == 0
772+
if tid == 0 && !GC.in_finalizer()
773773
# Issue #41324
774774
# t.sticky && tid == 0 is a task that needs to be co-scheduled with
775775
# the parent task. If the parent (current_task) is not sticky we must

0 commit comments

Comments
 (0)