We have a bit of fairly complicated logic in our project that uses an IsoMutableMap whose value is another IsoMutableMap, something like
val nested = IsoMutableMap<Int, IsoMutableMap<Int, Int>>()
As part of a recent change, we ended up with some code that boils down to
nested.access {
it[0] = IsoMutableMap()
}
and were surprised to find that this causes a deadlock:
IsoMutableMap constructor calls createState
- That function isn't aware of the
StateHolder so it just directly calls runner.stateRun, not realizing we're already on the thread it wants to run on
- Work gets enqueued to run on the current thread later
- Current thread blocks on that future work - deadlock
Not sure if there's a clean way that the threading information could be conveyed here to do the right thing.