Thanks again for saving me from the utter nightmare to debug such an issue, and explaining julia internals along the way. I shall now give up, for the time being, and just avoid concurrent writes of object references.
Just for curiosity, is this fixable with llvm code to root the inserted object? Or am I misunderstanding, again, some subtlety in the julia implementation?
One could do a copy-pasta from e.g.
set_(X,i,nv) = @inbounds X[i]=nv;
code_llvm(set_, (Vector{Vector{Int64}}, Int64, Vector{Int64}))
exchanging the actual store for a cas (the new object may get rooted even if the write fails. The caller would need to keep the object visible until he has verified whether the write was successful - for example, by actually using the object he attempted to insert in the “failed insert” branch, or in some de-facto unreachable branch that cannot be inferred to be unreachable.
This would, however, probably not be worth it with respect to maintainability and API-uglyness? (otherwise you would have done it already in atomics.jl? or are there other hidden dragons?)