Как включить LSAN обнаруживать утечки памяти во время выполнения, а не ждать до конца процесса - PullRequest
1 голос
/ 09 марта 2020

У меня есть процесс "deamon" с инструментарием ASAN, который всегда выполняется в моей системе. Я вижу, утечки памяти сообщаются только при выходе из процесса. В любом случае я могу попросить LSAN сбросить отчеты об утечках, не убивая процесс? Есть ли какой-нибудь сигнал, который я могу отправить процессу, чтобы он обнаруживал и выводил утечки?

1 Ответ

0 голосов
/ 11 марта 2020

Использование __ lsan_do_leak_check :

  // Check for leaks now. This function behaves identically to the default
  // end-of-process leak check. In particular, it will terminate the process if
  // leaks are found and the exitcode runtime flag is non-zero.
  // Subsequent calls to this function will have no effect and end-of-process
  // leak check will not run. Effectively, end-of-process leak check is moved to
  // the time of first invocation of this function.
  // By calling this function early during process shutdown, you can instruct
  // LSan to ignore shutdown-only leaks which happen later on.
...