Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(391)

Unified Diff: third_party/WebKit/Source/platform/heap/Handle.h

Issue 1491253004: Release Oilpan heap singletons prior to LSan leak detection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address non-LSan Oilpan compilation failure Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/heap/Handle.h
diff --git a/third_party/WebKit/Source/platform/heap/Handle.h b/third_party/WebKit/Source/platform/heap/Handle.h
index 9ef17dedb23ab35406e19a1e1e774f52269c40af..a585ac832b03ae1955c647e43186b9f5f395c363 100644
--- a/third_party/WebKit/Source/platform/heap/Handle.h
+++ b/third_party/WebKit/Source/platform/heap/Handle.h
@@ -46,6 +46,10 @@
#include "wtf/RefCounted.h"
#include "wtf/TypeTraits.h"
+#if defined(LEAK_SANITIZER)
+#include "wtf/LeakAnnotations.h"
+#endif
+
namespace blink {
enum WeaknessPersistentConfiguration {
@@ -183,6 +187,17 @@ public:
return *this;
}
+#if defined(LEAK_SANITIZER)
+ PersistentBase* registerAsStaticReference()
+ {
+ if (m_persistentNode) {
+ ASSERT(ThreadState::current());
+ ThreadState::current()->registerStaticPersistentNode(m_persistentNode);
+ LEAK_SANITIZER_IGNORE_OBJECT(this);
+ }
+ return this;
+ }
+#endif
private:
NO_LAZY_SWEEP_SANITIZE_ADDRESS
@@ -545,7 +560,20 @@ public:
visitor->trace(*static_cast<Collection*>(this));
}
+#if defined(LEAK_SANITIZER)
+ PersistentHeapCollectionBase* registerAsStaticReference()
+ {
+ if (m_persistentNode) {
+ ASSERT(ThreadState::current());
+ ThreadState::current()->registerStaticPersistentNode(m_persistentNode);
+ LEAK_SANITIZER_IGNORE_OBJECT(this);
+ }
+ return this;
+ }
+#endif
+
private:
+
NO_LAZY_SWEEP_SANITIZE_ADDRESS
void initialize()
{
@@ -1066,8 +1094,13 @@ template<typename T> T* adoptPtrWillBeNoop(T* ptr)
#define DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(type) // do nothing
#define DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(type) // do nothing
+#if defined(LEAK_SANITIZER)
+#define DEFINE_STATIC_REF_WILL_BE_PERSISTENT(type, name, arguments) \
+ static type* name = *(new Persistent<type>(arguments))->registerAsStaticReference()
+#else
#define DEFINE_STATIC_REF_WILL_BE_PERSISTENT(type, name, arguments) \
- static type* name = (new Persistent<type>(arguments))->get();
+ static type* name = *(new Persistent<type>(arguments))
+#endif
#else // !ENABLE(OILPAN)
@@ -1266,6 +1299,35 @@ private:
CrossThreadWeakPersistent<T> m_value;
};
+// LEAK_SANITIZER_DISABLED_SCOPE: all allocations made in the current scope
+// will be exempted from LSan consideration.
+//
+// TODO(sof): move this to wtf/LeakAnnotations.h (LeakSanitizer.h?) once
+// wtf/ can freely call upon Oilpan functionality.
+#if defined(LEAK_SANITIZER)
+class LeakSanitizerDisableScope {
+ STACK_ALLOCATED();
+ WTF_MAKE_NONCOPYABLE(LeakSanitizerDisableScope);
+public:
+ LeakSanitizerDisableScope()
+ {
+ __lsan_disable();
+ if (ThreadState::current())
+ ThreadState::current()->enterStaticReferenceRegistrationDisabledScope();
+ }
+
+ ~LeakSanitizerDisableScope()
+ {
+ __lsan_enable();
+ if (ThreadState::current())
+ ThreadState::current()->leaveStaticReferenceRegistrationDisabledScope();
+ }
+};
+#define LEAK_SANITIZER_DISABLED_SCOPE LeakSanitizerDisableScope lsanDisabledScope
+#else
+#define LEAK_SANITIZER_DISABLED_SCOPE
+#endif
+
} // namespace blink
namespace WTF {
« no previous file with comments | « third_party/WebKit/Source/platform/WebThreadSupportingGC.cpp ('k') | third_party/WebKit/Source/platform/heap/ThreadState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698