@@ -54,6 +54,8 @@ extern "C" {
5454
5555void __asan_poison_memory_region (void const volatile * addr , size_t size );
5656void __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 );
5759
5860/// Marks a memory region as unaddressable.
5961///
@@ -73,6 +75,25 @@ void __asan_unpoison_memory_region(void const volatile *addr, size_t size);
7375/// \param size Size of memory region.
7476#define ASAN_UNPOISON_MEMORY_REGION (addr , size ) __asan_unpoison_memory_region((addr), (size))
7577
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(void)
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 () int __lsan_do_recoverable_leak_check(void)
96+
7697#ifdef __cplusplus
7798} // extern "C"
7899#endif
@@ -84,6 +105,9 @@ void __asan_unpoison_memory_region(void const volatile *addr, size_t size);
84105#define ASAN_UNPOISON_MEMORY_REGION (addr , size ) \
85106 ((void)(addr), (void)(size))
86107
108+ #define LSAN_DO_LEAK_CHECK () /**/
109+ #define LSAN_DO_RECOVERABLE_LEAK_CHECK () 0
110+
87111#endif // QD_HAS_ADDRESS_SANITIZER
88112
89113// https://github.com/google/sanitizers/wiki/AddressSanitizer#turning-off-instrumentation
0 commit comments