libasan
Background
For a business software, minimal error may lead critical issue in production environment.
In the company’s projects, we utilize address sanitization to identify potential issues, thereby enhancing the reliability of the program.
Introduction
AddressSanitizer (aka ASan) is a memory error detector for C/C++.
Practice
cat test_asan.c
#include <stdlib.h>
int test_use_after_free()
{
char *x = (char*)malloc(10 * sizeof(char*));
free(x);
return x[5];
}
void test_stack_overflow()
{
char buf[10] = {0};
memset(buf, 0, 20);
}
int main()
{
test_use_after_free();
test_stack_overflow();
return 0;
}
g++ -o bin_asan -g
Common Usages
References
Google AddressSanitizer
Wiki AddressSanitizer
https://llvm.org/docs/GettingStarted.html#getting-a-modern-host-c-toolchain
Comments