JuliaParallel / Dagger.jl

A framework for out-of-core and parallel execution
Other
638 stars 67 forks source link

`UNHANDLED TASK ERROR: ArgumentError: destination has fewer elements than required` #449

Closed StevenWhitaker closed 11 months ago

StevenWhitaker commented 12 months ago

I looked more into an error I reported previously in #437 (repeated below):

      From worker 3:    UNHANDLED TASK ERROR: ArgumentError: destination has fewer elements than required
      From worker 3:    Stacktrace:
      From worker 3:     [1] copyto!(dest::Vector{Dagger.Sch.ProcessorState}, src::Base.ValueIterator{Dict{Dagger.Processor, Dagger.Sch.ProcessorState}})
      From worker 3:       @ Base ./abstractarray.jl:949
      From worker 3:     [2] _collect
      From worker 3:       @ ./array.jl:713 [inlined]
      From worker 3:     [3] collect
      From worker 3:       @ ./array.jl:707 [inlined]
      From worker 3:     [4] macro expansion
      From worker 3:       @ ~/.julia/packages/Dagger/M13n0/src/sch/Sch.jl:1189 [inlined]
      From worker 3:     [5] (::Dagger.Sch.var"#128#135"{Dagger.Sch.ProcessorInternalState, UInt64, RemoteChannel{Channel{Any}}, Dagger.ThreadProc})()
      From worker 3:       @ Dagger.Sch ./task.jl:134

The offending line (line 1189 in the stacktrace): https://github.com/JuliaParallel/Dagger.jl/blob/d60fd3fbc3335abd41beb5386e3c91597a64afc2/src/sch/Sch.jl#L1210

proc_states(values, uid) returns a ValueIterator of all_states (which comes from PROCESSOR_TASK_STATE). Unfortunately, as I understand it, the lock is released before the call to collect, meaning all_states can change before collect finishes (i.e., after allocating memory, but before actually iterating through the values).

jpsamaroo commented 11 months ago

Good find!