@@ -54,6 +54,8 @@ extern "C" {
54
54
55
55
void __asan_poison_memory_region (void const volatile * addr , size_t size );
56
56
void __asan_unpoison_memory_region (void const volatile * addr , size_t size );
57
+ void __lsan_do_leak_check (void );
58
+ int __lsan_do_recoverable_leak_check (void );
57
59
58
60
/// Marks a memory region as unaddressable.
59
61
///
@@ -73,6 +75,25 @@ void __asan_unpoison_memory_region(void const volatile *addr, size_t size);
73
75
/// \param size Size of memory region.
74
76
#define ASAN_UNPOISON_MEMORY_REGION (addr , size ) __asan_unpoison_memory_region((addr), (size))
75
77
78
+ // Check for leaks now. This function behaves identically to the default
79
+ // end-of-process leak check. In particular, it will terminate the process if
80
+ // leaks are found and the exitcode runtime flag is non-zero.
81
+ // Subsequent calls to this function will have no effect and end-of-process
82
+ // leak check will not run. Effectively, end-of-process leak check is moved to
83
+ // the time of first invocation of this function.
84
+ // By calling this function early during process shutdown, you can instruct
85
+ // LSan to ignore shutdown-only leaks which happen later on.
86
+ #define LSAN_DO_LEAK_CHECK () __lsan_do_leak_check()
87
+
88
+ // Check for leaks now. Returns zero if no leaks have been found or if leak
89
+ // detection is disabled, non-zero otherwise.
90
+ // This function may be called repeatedly, e.g. to periodically check a
91
+ // long-running process. It prints a leak report if appropriate, but does not
92
+ // terminate the process. It does not affect the behavior of
93
+ // __lsan_do_leak_check() or the end-of-process leak check, and is not
94
+ // affected by them.
95
+ #define LSAN_DO_RECOVERABLE_LEAK_CHECK () __lsan_do_recoverable_leak_check()
96
+
76
97
#ifdef __cplusplus
77
98
} // extern "C"
78
99
#endif
@@ -84,6 +105,9 @@ void __asan_unpoison_memory_region(void const volatile *addr, size_t size);
84
105
#define ASAN_UNPOISON_MEMORY_REGION (addr , size ) \
85
106
((void)(addr), (void)(size))
86
107
108
+ #define LSAN_DO_LEAK_CHECK () /**/
109
+ #define LSAN_DO_RECOVERABLE_LEAK_CHECK () 0
110
+
87
111
#endif // QD_HAS_ADDRESS_SANITIZER
88
112
89
113
// https://github.com/google/sanitizers/wiki/AddressSanitizer#turning-off-instrumentation
0 commit comments