-
Notifications
You must be signed in to change notification settings - Fork 274
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[asan] add address sanitizer support for syncd
* add --enable-asan for syncd compilation * add SIGTERM handler that calls __lsan_do_leak_check() to generate a report Signed-off-by: Yakiv Huryk <yhuryk@nvidia.com>
- Loading branch information
1 parent
7a2b824
commit 98fc234
Showing
4 changed files
with
50 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,32 @@ | ||
#include "swss/logger.h" | ||
|
||
#if defined(ASAN_ENABLED) | ||
#include <csignal> | ||
#include <sanitizer/lsan_interface.h> | ||
|
||
void sigterm_handler(int signo) | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
__lsan_do_leak_check(); | ||
signal(signo, SIG_DFL); | ||
raise(signo); | ||
} | ||
#endif | ||
|
||
int syncd_main(int argc, char **argv); | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
#if defined(ASAN_ENABLED) | ||
if (signal(SIGTERM, sigterm_handler) == SIG_ERR) | ||
{ | ||
SWSS_LOG_ERROR("failed to setup SIGTERM action"); | ||
exit(1); | ||
} | ||
#endif | ||
|
||
return syncd_main(argc, argv); | ||
} |