[PATCH] Fix initialization problems with PassRegistry
dblaikie at gmail.com
Wed Jun 11 10:54:50 PDT 2014
Ah, right, the PassRegistry's dtor accesses the lock. Why? It's running as a global dtor - do they ever run concurrently? (I know at Google we have a rule of no global dtors since you might be in the middle of a thread, holding a lock, when the process gets shutdown - at which point you'll deadlock in your global ctor. I'm not sure if we want to go that far & not sure how that'd work with llvm_shutdown)
It still seems a bit error prone to have a global object (PassRegistry) access another global (its lock) in a dtor without any guarantee that PassRegistry is initialized after the lock...
If the PassRegistry's dtor actually needs to lock, then it sounds like the program will have a race on the lock (since it's handling the lock in some other thread during destruction and the lock will be destroyed at some point here) - so I'm not sure if your change actually makes any of this actually safe?
More information about the llvm-commits