https://github.com/yugr/failing-malloc
A simple 5-minute checker which simulates OOM failures by returning NULL from malloc
https://github.com/yugr/failing-malloc
checker malloc runtime-verification
Last synced: 10 months ago
JSON representation
A simple 5-minute checker which simulates OOM failures by returning NULL from malloc
- Host: GitHub
- URL: https://github.com/yugr/failing-malloc
- Owner: yugr
- License: mit
- Created: 2021-06-09T22:43:25.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-06-12T12:40:00.000Z (over 4 years ago)
- Last Synced: 2025-03-25T09:52:58.361Z (10 months ago)
- Topics: checker, malloc, runtime-verification
- Language: C
- Homepage:
- Size: 5.86 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
A simple 5-minute checker which simulates OOM failures
by returning `NULL` from `malloc` and friends.
This project is developed for [Lalambda '21 school](https://lalambda.school/en)
and is meant for educational purposes only.
BRANCHES IN THIS REPO MAY BE FORCED CHANGED AT ANY MOMENT.
# Usage
To instrument programs need to either `export LD_PRELOAD=path/to/libfailingmalloc.so`
or `echo path/to/libfailingmalloc.so >> /etc/ld.so.preload`.
Options are supplied through environment variables:
* `FAILING_MALLOC_FAIL_AFTER` - do not try to return `NULL`
for first `N` calls
* `FAILING_MALLOC_LOGFILE` - dump logs to file (instead of stderr)
To fuzz an app run it in a loop:
```
$ while true; do
export FAILING_MALLOC_FAIL_AFTER=$((`od -vAn -N1 -tu1 < /dev/urandom` >> 5))
LD_PRELOAD=path/to/libfailingmalloc.so myapp
sleep 0.5
done
```