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 reachability traversal is stopped short |
| 75 // upon encountering an ignored memory chunk. Consequently, LSan will not |
| 76 // scan an ignored memory chunk for live, reachable pointers. However, should |
| 77 // those embedded pointers be reachable by some other path, they will be |
| 78 // reported as leaking. |
77 #define LEAK_SANITIZER_IGNORE_OBJECT(X) __lsan_ignore_object(X) | 79 #define LEAK_SANITIZER_IGNORE_OBJECT(X) __lsan_ignore_object(X) |
78 | 80 |
79 // If the object pointed to by the static local is on the Oilpan heap, a strong | 81 // 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 | 82 // 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 | 83 // 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
, | 84 // detection pass. We do not want these intentional leaks to be reported by LSan
, |
83 // hence the static local is registered with Oilpan | 85 // hence the static local is registered with Oilpan |
84 // (see RegisterStaticLocalReference<> below.) | 86 // (see RegisterStaticLocalReference<> below.) |
85 // | 87 // |
86 // Upon Blink shutdown, all the registered statics are released and a final roun
d | 88 // 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) | 131 #define LEAK_SANITIZER_REGISTER_STATIC_LOCAL(Type, Object) WTF::RegisterStaticLo
calReference<Type>::registerStatic(Object) |
130 #else | 132 #else |
131 #define WTF_INTERNAL_LEAK_SANITIZER_DISABLED_SCOPE | 133 #define WTF_INTERNAL_LEAK_SANITIZER_DISABLED_SCOPE |
132 #define LEAK_SANITIZER_IGNORE_OBJECT | 134 #define LEAK_SANITIZER_IGNORE_OBJECT |
133 #define LEAK_SANITIZER_REGISTER_STATIC_LOCAL(Type, Object) Object | 135 #define LEAK_SANITIZER_REGISTER_STATIC_LOCAL(Type, Object) Object |
134 #endif // USE(LEAK_SANITIZER) | 136 #endif // USE(LEAK_SANITIZER) |
135 | 137 |
136 } // namespace WTF | 138 } // namespace WTF |
137 | 139 |
138 #endif // WTF_LeakAnnotations_h | 140 #endif // WTF_LeakAnnotations_h |
OLD | NEW |