Skip to content

ConcurrencyViolationError when multiple OutputCollectors run in parallel in v0.1 series #12

@IanButterworth

Description

@IanButterworth

(Found and written by Claude)

When using OutputCollector from multiple threads simultaneously, a ConcurrencyViolationError is thrown because notify is called on a Condition without holding the associated lock.

Error:

ConcurrencyViolationError("lock must be held")
Stacktrace:
 [1] concurrency_violation()
   @ Base ./condition.jl:8
 [2] assert_havelock
   @ ./condition.jl:25 [inlined]
 [3] assert_havelock
   @ ./condition.jl:48 [inlined]
 [4] assert_havelock
   @ ./condition.jl:74 [inlined]
 [5] notify(c::Condition, arg::Any, all::Bool, error::Bool)
   @ Base ./condition.jl:161
 [6] notify (repeats 2 times)
   @ ./condition.jl:159 [inlined]
 [7] (::OutputCollectors.var"#LineStream##0#LineStream##1"{Pipe, Condition, Vector{Tuple{Float64, String}}})()
   @ OutputCollectors ~/.julia/packages/OutputCollectors/c0ZGU/src/OutputCollectors.jl:68

Context:

This was discovered when BinaryBuilder.jl ran sandbox operations in parallel (via Threads.@threads). Each sandbox operation creates its own OutputCollector, but the error suggests there's some shared state or the Condition usage isn't thread-safe.

Looking at line 68 in OutputCollectors.jl, there's a notify(c) call that needs to be wrapped in a lock.

Julia Version: 1.12

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