Skip to content

Darwin/ARM64: Julia freezes on nested @threads loops #41820

Closed

Description

The arm64 native 1.7-beta3 sometimes hangs on nested threaded loops.

MWE:

using Base.Threads: @threads

function foo()
    @threads for i in 1:10
        bar()
    end
end

function bar()
    @threads for i in 1:10
        rand(100)
    end
end

for i in 1:1000
    println(i)
    for j in 1:10000
        foo()
    end
end

Hangs for me after ~20-500 printed numbers. The non-minimal code was ^C-interruptable with the following stacktrace:

ERROR: InterruptException:
Stacktrace:
  [1] poptask(W::Base.InvasiveLinkedListSynchronized{Task})
    @ Base ./task.jl:814
  [2] wait
    @ ./task.jl:822 [inlined]
  [3] wait(c::Base.GenericCondition{Base.Threads.SpinLock})
    @ Base ./condition.jl:112
  [4] _wait(t::Task)
    @ Base ./task.jl:293
  [5] wait
    @ ./task.jl:320 [inlined]
  [6] threading_run(func::Function)
    @ Base.Threads ./threadingconstructs.jl:38
  [7] macro expansion
    @ ./threadingconstructs.jl:97 [inlined]
julia> versioninfo()
Julia Version 1.7.0-beta3
Commit e76c9dad42* (2021-07-07 08:12 UTC)
Platform Info:
  OS: macOS (arm64-apple-darwin20.5.0)
  CPU: Apple M1
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.0 (ORCJIT, cyclone)

ref #36617 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    multithreadingBase.Threads and related functionalitysystem:apple siliconAffects Apple Silicon only (Darwin/ARM64) - e.g. M1 and other M-series chipssystem:macAffects only macOS

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions