forked from OSchip/llvm-project
Fix an order-of-deallocation issue where the AttrListImpl could be deallocated before the global
LLVMContext, causing memory errors. Patch by Peter Collingbourne. llvm-svn: 119721
This commit is contained in:
parent
4e78f60660
commit
2e831897d6
|
@ -106,6 +106,11 @@ Attributes Attribute::typeIncompatible(const Type *Ty) {
|
|||
// AttributeListImpl Definition
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
namespace llvm {
|
||||
class AttributeListImpl;
|
||||
}
|
||||
|
||||
static ManagedStatic<FoldingSet<AttributeListImpl> > AttributesLists;
|
||||
|
||||
namespace llvm {
|
||||
static ManagedStatic<sys::SmartMutex<true> > ALMutex;
|
||||
|
@ -131,6 +136,8 @@ public:
|
|||
}
|
||||
void DropRef() {
|
||||
sys::SmartScopedLock<true> Lock(*ALMutex);
|
||||
if (!AttributesLists.isConstructed())
|
||||
return;
|
||||
sys::cas_flag new_val = --RefCount;
|
||||
if (new_val == 0)
|
||||
delete this;
|
||||
|
@ -147,8 +154,6 @@ public:
|
|||
};
|
||||
}
|
||||
|
||||
static ManagedStatic<FoldingSet<AttributeListImpl> > AttributesLists;
|
||||
|
||||
AttributeListImpl::~AttributeListImpl() {
|
||||
// NOTE: Lock must be acquired by caller.
|
||||
AttributesLists->RemoveNode(this);
|
||||
|
|
Loading…
Reference in New Issue