What happens if an object is converted to its stab...
# kotlin-native
n
What happens if an object is converted to its stable address with
StableRef.create(item).asCPointer().toLong()
, then it is passed outside of the K/N runtime, then it comes back on another thread and you fetch the item again with something like
long.toCPointer<CPointed>()?.asStableRef<Item>()
? Would you end up with the two `Item`s that point to the same location in memory, and that can be accessed concurrently from the two threads? So overcoming the current memory model. Or would this fail, and if so how?
s
Starting from 1.4 it would fail with
IncorrectDereferenceException
. Unless the object is frozen of course.
n
Interesting, thanks a lot!
👍 1