NetLogo/NetLogo — Issue #86: 5.0 regression: `stop` sometimes later interferes with later execution
Author: SethTisue
Created: 2012-02-20 19:23:38+00:00
State: open

reported by Christopher Watts against 5.0.0

I reduced his code to this perhaps minimal test case:

```text
to test
ca crt 1 [ halt k ]
end
to halt stop end
to k
let c 0
foreach [0] [
foreach [0] [
if true [ ]
set c 0
]
]
end
```

Minor variations are possible, for example removing the useless `if` leads to an infinite loop instead of the usual result which is this ArrayIndexOutOfBoundsException:

```text
java.lang.ArrayIndexOutOfBoundsException: 2
at org.nlogo.nvm.Context.runExclusive(Context.java:115)
at org.nlogo.nvm.CommandTask.perform(Task.scala:81)
at org.nlogo.prim.etc._foreach.perform(_foreach.scala:35)
at org.nlogo.nvm.Context.runExclusive(Context.java:119)
at org.nlogo.nvm.ExclusiveJob.run(ExclusiveJob.java:56)
at org.nlogo.nvm.Context.runExclusiveJob(Context.java:161)
at org.nlogo.prim._createturtles.perform(_createturtles.java:57)
at org.nlogo.nvm.Context.stepConcurrent(Context.java:91)
at org.nlogo.nvm.ConcurrentJob.step(ConcurrentJob.java:82)
at org.nlogo.job.JobThread.org$nlogo$job$JobThread$$runPrimaryJobs(JobThread.scala:143)
```