Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fanyang89/gwp-asan
Standalone gwp-asan from LLVM
https://github.com/fanyang89/gwp-asan
address-sanitizer gwp-asan llvm sanitizer sanitizers
Last synced: about 1 month ago
JSON representation
Standalone gwp-asan from LLVM
- Host: GitHub
- URL: https://github.com/fanyang89/gwp-asan
- Owner: fanyang89
- Created: 2024-06-03T09:33:29.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-06-06T09:19:19.000Z (6 months ago)
- Last Synced: 2024-10-01T03:40:52.519Z (about 2 months ago)
- Topics: address-sanitizer, gwp-asan, llvm, sanitizer, sanitizers
- Language: C++
- Homepage: https://github.com/fanyang89/gwp-asan
- Size: 698 KB
- Stars: 2
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# gwp-asan
Independent standalone gwp-asan, from [llvm](https://github.com/llvm/llvm-project)
## What's this
GWP-ASan is a sampled allocator framework that assists in finding use-after-free and heap-buffer-overflow bugs in
**production** environments.This repo contains a standalone gwp-asan, you can easily use it with CMake.
Check the documents here: [gwp-asan](https://llvm.org/docs/GwpAsan.html)
## Integration
TL;DR read the [example](https://github.com/fanyang89/gwp-asan/blob/main/example/helloworld/main.cc)
Integration by simply performing the following steps:
1. add hook to malloc/free
```c++
void *operator new(std::size_t sz) {
if (allocator.shouldSample()) {
return allocator.allocate(sz, MinAlignment);
}
return malloc(sz);
}void operator delete(void *ptr) {
if (allocator.pointerIsMine(ptr)) {
allocator.deallocate(ptr);
return;
}
free(ptr);
}
```2. register SEGV handler and init the allocator
```c++
gwp_asan::options::Options options;
options.Enabled = true;
options.MaxSimultaneousAllocations = 16;
options.SampleRate = 3;
options.Backtrace = gwp_asan::backtrace::getBacktraceFunction();
allocator.init(options);
gwp_asan::segv_handler::installSignalHandlers(
&allocator, PrintfToBuffer,
gwp_asan::backtrace::getPrintBacktraceFunction(),
gwp_asan::backtrace::getSegvBacktraceFunction(),
false
);
```## Resolve output
```bash
./buggy-program | ./scripts/symbolize.sh
```