SimJulia, interrupt() error

When interrupt one process which have an event with callback function, an error occurs. The small example code is as follows.

function my_callback(ev::AbstractEvent, env::Environment)
  println("Called back from ", ev)
  println( "callback time: ", now(env) )
end

@resumable function charge(env::Environment, duration::Number)
    @yield timeout(env, duration)
end

@resumable function driver(env::Environment, car_process::Process)
    @yield timeout(env, 3)
    @yield interrupt(car_process)
end

@resumable function car(env::Environment)
  while true
    println("Start parking and charging at ", now(env))
    charge_duration = 5
    charge_process = @process charge(sim, charge_duration)
    @callback my_callback( charge_process, env )   # no error without this line

    try
      @yield charge_process
    catch e
      println("Was interrupted. Hopefully, the battery is full enough ...")
      #rethrow(e)
    end
    println("Start driving at ", now(env))
    trip_duration = 2
    @yield timeout(sim, trip_duration)
    println("Now: ", now(env))
  end
end

#####################################
sim = Simulation()

car_process = @process car(sim)
@process driver(sim, car_process)

run(sim, 15)

The error is as follows,

Start parking and charging at 0.0
ERROR: LoadError: LoadError: MethodError: no method matching iterate(::Nothing)
Closest candidates are:
  iterate(::Core.SimpleVector) at essentials.jl:568
  iterate(::Core.SimpleVector, ::Any) at essentials.jl:568
  iterate(::ExponentialBackOff) at error.jl:199
  ...
Stacktrace:
 [1] _deleteat!(::Array{Function,1}, ::Nothing) at ./array.jl:1217
 [2] deleteat!(::Array{Function,1}, ::Nothing) at ./array.jl:1212
 [3] remove_callback(::Function, ::Process) at /Users/zhangliye/.julia/packages/SimHPC/ljsCA/src/base.jl:63
 [4] execute_interrupt(::SimHPC.Interrupt, ::Process) at /Users/zhangliye/.julia/packages/SimHPC/ljsCA/src/processes.jl:53
 [5] (::getfield(SimHPC, Symbol("##3#4")){typeof(SimHPC.execute_interrupt),SimHPC.Interrupt,Tuple{Process}})() at /Users/zhangliye/.julia/packages/SimHPC/ljsCA/src/base.jl:51
 [6] step(::Simulation) at /Users/zhangliye/.julia/packages/SimHPC/ljsCA/src/simulations.jl:39
 [7] run(::Simulation, ::SimHPC.Timeout) at /Users/zhangliye/.julia/packages/SimHPC/ljsCA/src/base.jl:91
 [8] run(::Simulation, ::Int64) at /Users/zhangliye/.julia/packages/SimHPC/ljsCA/src/events.jl:29
 [9] top-level scope at none:0
 [10] include at ./boot.jl:326 [inlined]
 [11] include_relative(::Module, ::String) at ./loading.jl:1038
 [12] include(::Module, ::String) at ./sysimg.jl:29
 [13] include(::String) at ./client.jl:403
 [14] top-level scope at none:0
 [15] include at ./boot.jl:326 [inlined]
 [16] include_relative(::Module, ::String) at ./loading.jl:1038
 [17] include(::Module, ::String) at ./sysimg.jl:29
 [18] include(::String) at ./client.jl:403
 [19] top-level scope at none:0
in expression starting at /Users/zhangliye/julia_dev/LDTSim/test/test_lib.jl:134
in expression starting at /Users/zhangliye/julia_dev/LDTSim/test/runtests.jl:5
ERROR: Package LTDSim errored during testing

Julia version information is as follows,

Julia Version 1.1.0
Commit 80516ca202 (2019-01-21 21:24 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin14.5.0)
  CPU: Intel(R) Core(TM) i5-8500 CPU @ 3.00GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, skylake)
Environment:
  JULIA_NUM_THREADS = 6

Hi @zhangliye,

I ran into this same issue! I found a fix for it. The remove_callback function needed to be improved as shown in this PR: Make remove_callback more robust by hdavid16 · Pull Request #72 · BenLauwens/SimJulia.jl · GitHub

Let me know if it works.