OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * Copyright (C) 2013 Samsung Electronics. All rights reserved. | 3 * Copyright (C) 2013 Samsung Electronics. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 16 matching lines...) Expand all Loading... | |
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 */ | 30 */ |
31 | 31 |
32 #ifndef WTF_LeakAnnotations_h | 32 #ifndef WTF_LeakAnnotations_h |
33 #define WTF_LeakAnnotations_h | 33 #define WTF_LeakAnnotations_h |
34 | 34 |
35 // This file defines macros for working with LeakSanitizer, allowing memory | 35 // This file defines macros for working with LeakSanitizer, allowing memory |
36 // and allocations to be registered as exempted from LSan consideration. | 36 // and allocations to be registered as exempted from LSan consideration. |
37 // | 37 |
38 // LSan exempted memory will be treated as a source of live pointers, | |
39 // i.e. heap objects reachable by following pointers from an exempted | |
40 // object will not be reported as leaks. | |
41 // | |
42 #include "wtf/Noncopyable.h" | 38 #include "wtf/Noncopyable.h" |
43 #if USE(LEAK_SANITIZER) | 39 #if USE(LEAK_SANITIZER) |
44 #include "wtf/AddressSanitizer.h" | 40 #include "wtf/AddressSanitizer.h" |
45 #include "wtf/TypeTraits.h" | 41 #include "wtf/TypeTraits.h" |
46 #endif | 42 #endif |
47 | 43 |
48 namespace WTF { | 44 namespace WTF { |
49 | 45 |
50 #if USE(LEAK_SANITIZER) | 46 #if USE(LEAK_SANITIZER) |
51 class LeakSanitizerDisabler { | 47 class LeakSanitizerDisabler { |
(...skipping 15 matching lines...) Expand all Loading... | |
67 // used internal to wtf/, Blink should use LEAK_SANITIZER_DISABLED_SCOPE | 63 // used internal to wtf/, Blink should use LEAK_SANITIZER_DISABLED_SCOPE |
68 // elsewhere. | 64 // elsewhere. |
69 // | 65 // |
70 // TODO(sof): once layering rules allow wtf/ to make use of the Oilpan | 66 // TODO(sof): once layering rules allow wtf/ to make use of the Oilpan |
71 // infrastructure, remove this macro. | 67 // infrastructure, remove this macro. |
72 #define WTF_INTERNAL_LEAK_SANITIZER_DISABLED_SCOPE \ | 68 #define WTF_INTERNAL_LEAK_SANITIZER_DISABLED_SCOPE \ |
73 WTF::LeakSanitizerDisabler leakSanitizerDisabler; static_cast<void>(0) | 69 WTF::LeakSanitizerDisabler leakSanitizerDisabler; static_cast<void>(0) |
74 | 70 |
75 // LEAK_SANITIZER_IGNORE_OBJECT(X): the heap object referenced by pointer X | 71 // LEAK_SANITIZER_IGNORE_OBJECT(X): the heap object referenced by pointer X |
76 // will be ignored by LSan. | 72 // will be ignored by LSan. |
73 // | |
74 // "Ignorance" means that LSan's leak detection pass will not consider the | |
75 // ignored memory chunk as leaking. Furthermore, the LSan reachability | |
76 // pass will not scan an ignored memory chunk for live, reachable pointers. | |
77 // So, should any of the pointers of that ignored chunk not be reachable | |
78 // from elsewhere, they'll be unreachable and thus not be reported as leaking. | |
79 // | |
80 // Notice that LSan will not transitively compute what's reachable from an | |
81 // ignored memory chunk and consider that set as ignored and unreachable. | |
haraken
2015/12/11 09:46:36
Slightly better: lsan_ignore_object(X) means that
sof
2015/12/11 10:03:37
A bit too brief perhaps? It ignores the object at
| |
77 #define LEAK_SANITIZER_IGNORE_OBJECT(X) __lsan_ignore_object(X) | 82 #define LEAK_SANITIZER_IGNORE_OBJECT(X) __lsan_ignore_object(X) |
78 | 83 |
79 // If the object pointed to by the static local is on the Oilpan heap, a strong | 84 // If the object pointed to by the static local is on the Oilpan heap, a strong |
80 // Persistent<> is created to keep the pointed-to heap object alive. This makes | 85 // Persistent<> is created to keep the pointed-to heap object alive. This makes |
81 // both the Persistent<> and the heap object _reachable_ by LeakSanitizer's leak | 86 // both the Persistent<> and the heap object _reachable_ by LeakSanitizer's leak |
82 // detection pass. We do not want these intentional leaks to be reported by LSan , | 87 // detection pass. We do not want these intentional leaks to be reported by LSan , |
83 // hence the static local is registered with Oilpan | 88 // hence the static local is registered with Oilpan |
84 // (see RegisterStaticLocalReference<> below.) | 89 // (see RegisterStaticLocalReference<> below.) |
85 // | 90 // |
86 // Upon Blink shutdown, all the registered statics are released and a final roun d | 91 // Upon Blink shutdown, all the registered statics are released and a final roun d |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 #define LEAK_SANITIZER_REGISTER_STATIC_LOCAL(Type, Object) WTF::RegisterStaticLo calReference<Type>::registerStatic(Object) | 134 #define LEAK_SANITIZER_REGISTER_STATIC_LOCAL(Type, Object) WTF::RegisterStaticLo calReference<Type>::registerStatic(Object) |
130 #else | 135 #else |
131 #define WTF_INTERNAL_LEAK_SANITIZER_DISABLED_SCOPE | 136 #define WTF_INTERNAL_LEAK_SANITIZER_DISABLED_SCOPE |
132 #define LEAK_SANITIZER_IGNORE_OBJECT | 137 #define LEAK_SANITIZER_IGNORE_OBJECT |
133 #define LEAK_SANITIZER_REGISTER_STATIC_LOCAL(Type, Object) Object | 138 #define LEAK_SANITIZER_REGISTER_STATIC_LOCAL(Type, Object) Object |
134 #endif // USE(LEAK_SANITIZER) | 139 #endif // USE(LEAK_SANITIZER) |
135 | 140 |
136 } // namespace WTF | 141 } // namespace WTF |
137 | 142 |
138 #endif // WTF_LeakAnnotations_h | 143 #endif // WTF_LeakAnnotations_h |
OLD | NEW |