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

Unified Diff: third_party/WebKit/Source/wtf/StdLibExtras.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
« no previous file with comments | « third_party/WebKit/Source/wtf/LeakAnnotations.h ('k') | third_party/WebKit/Source/wtf/text/StringImpl.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/StdLibExtras.h
diff --git a/third_party/WebKit/Source/wtf/StdLibExtras.h b/third_party/WebKit/Source/wtf/StdLibExtras.h
index 62acd8582e0fdf7eee3a7b68cec156a9236f5512..623fd15af0436effed7eef24c8d001d64a5e7de6 100644
--- a/third_party/WebKit/Source/wtf/StdLibExtras.h
+++ b/third_party/WebKit/Source/wtf/StdLibExtras.h
@@ -29,6 +29,7 @@
#include "wtf/Assertions.h"
#include "wtf/CPU.h"
#include "wtf/CheckedArithmetic.h"
+#include "wtf/LeakAnnotations.h"
#include <cstddef>
#if ENABLE(ASSERT)
@@ -58,31 +59,30 @@ private:
};
#endif
-// Use this to declare and define a static local variable (static T;) so that
-// it is leaked so that its destructors are not called at exit.
-#ifndef DEFINE_STATIC_LOCAL
-
+// Use DEFINE_STATIC_LOCAL() to declare and define a static local variable (static T;)
+// so that it is leaked and its destructors are not called at exit.
+//
+// To cooperate with leak detection, the objects held onto by these local statics
+// will in some cases have to be finalized prior to leak checking. This only applies
+// to static references to Oilpan heap objects and what they transitively hold on to.
+// LEAK_SANITIZER_REGISTER_STATIC_LOCAL() takes care of the details.
+//
#if ENABLE(ASSERT)
#define DEFINE_STATIC_LOCAL(type, name, arguments) \
static StaticLocalVerifier name##StaticLocalVerifier; \
- ASSERT(name##StaticLocalVerifier.isNotRacy()); \
- static type& name = *new type arguments
+ ASSERT(name##StaticLocalVerifier.isNotRacy()); \
+ static type& name = *LEAK_SANITIZER_REGISTER_STATIC_LOCAL(type, new type arguments)
#else
#define DEFINE_STATIC_LOCAL(type, name, arguments) \
- static type& name = *new type arguments
-#endif
-
+ static type& name = *LEAK_SANITIZER_REGISTER_STATIC_LOCAL(type, new type arguments)
#endif
-
// Use this to declare and define a static local pointer to a ref-counted object so that
// it is leaked so that the object's destructors are not called at exit.
// This macro should be used with ref-counted objects rather than DEFINE_STATIC_LOCAL macro,
// as this macro does not lead to an extra memory allocation.
-#ifndef DEFINE_STATIC_REF
#define DEFINE_STATIC_REF(type, name, arguments) \
static type* name = PassRefPtr<type>(arguments).leakRef();
-#endif
/*
* The reinterpret_cast<Type1*>([pointer to Type2]) expressions - where
« no previous file with comments | « third_party/WebKit/Source/wtf/LeakAnnotations.h ('k') | third_party/WebKit/Source/wtf/text/StringImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698