Skip to content

Suppressed error in task inside @sync block can cause deadlock #61228

@hawahee

Description

@hawahee

A deadlock can happen if you use Threads.@spawn to create two or more tasks inside a @sync block and an error happens inside a task that is crucial for all tasks to complete. It seems that the error is suppressed and the error task never completes, which as expected causes the other task(s) to not complete. I would expect the error task to not suppress the error and instead fail.

Example to cause a deadlock:

@sync begin
    c = Channel{Int}()
    Threads.@spawn take!(c)              # will block until an int is put! on the channel
    Threads.@spawn put!(c, "wrong")      # will block until a take! on the channel
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions