summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2010-11-18 18:59:13 +0000
committerOwen Anderson <resistor@mac.com>2010-11-18 18:59:13 +0000
commit2e831897d61a46ad627f16da00ec522c5a38b72d (patch)
tree67d30f4ed46cf0f4b66f18de506550483ff567bf /llvm
parent4e78f60660890d36c01e882339cc3f0ddb62a993 (diff)
downloadbcm5719-llvm-2e831897d61a46ad627f16da00ec522c5a38b72d.tar.gz
bcm5719-llvm-2e831897d61a46ad627f16da00ec522c5a38b72d.zip
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
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/VMCore/Attributes.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/VMCore/Attributes.cpp b/llvm/lib/VMCore/Attributes.cpp
index 477111a3ae8..e4a228b8c62 100644
--- a/llvm/lib/VMCore/Attributes.cpp
+++ b/llvm/lib/VMCore/Attributes.cpp
@@ -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);
OpenPOWER on IntegriCloud