Purpose of Epoch Trackers

Hi all,
I’m dealing with the multi-threaded code, in one of executions of the program I hitting an assertion failure, I’m not always getting the assertion failure when I run the executable but it occurs for say (1 in 10) times. I think there may be an thread race condition. I don’t know which is the root cause of this error because the assertion not explicitly occurs in my code, it occurs in the library code which I’m using in my threads.

Assertion I’m getting is this:

Global Value is CRO: /home/preejackie/spicy/orcs/llvm/include/llvm/ADT/DenseMap.h:1242: bool llvm::DenseMapIterator<const llvm::Value *, llvm::StringMapEntry<llvm::Value *> *, llvm::DenseMapInfo<const llvm::Value *>, llvm::detail::DenseMapPair<const llvm::Value *, llvm::StringMapEntry<llvm::Value *> *>, false>::operator!=(const llvm::DenseMapIterator::ConstIterator &) const [KeyT = const llvm::Value *, ValueT = llvm::StringMapEntry<llvm::Value *> *, KeyInfoT = llvm::DenseMapInfo<const llvm::Value *>, Bucket = llvm::detail::DenseMapPair<const llvm::Value *, llvm::StringMapEntry<llvm::Value *> *>, IsConst = false]: Assertion `(!Ptr || isHandleInSync()) && “handle not in sync!”’ failed.

It seems like the given assertion is defined in Epochtracker.h only for the debug build. My question is what is the purpose of Epochtrackers,h? Is it there to catch the race condition when accessing the densemap concurrently ?

Please tell me if you need more info
Thanks

Epoch tracking is meant to catch cases where an iterator might point to an invalid address due to another operation on the same DenseMap, on the same thread. For example, if you have a for loop that iterates over a DenseMap, and insert an element into that DenseMap inside the loop body.

Neither DenseMap nor the epoch tracking is threadsafe; if it’s catching a race condition, you’re getting lucky.

-Eli

Oh, then I think it may results from accessing / mutating data from different threads with different timed sequences of events. But I’m not sure which part in my code triggers this behaviour.

I will do more investigation tomorrow and let you know

Thanks