Giter Club home page Giter Club logo

mind_monitor's Introduction

Mind_Monitor

A comparison of various C Programming memory debuggers

MEMORY DEBUGGERS

  • Dmalloc
  • Electric Fence
  • Valgrind
  • Memwatch
  • Mtrace
  • AddressSanitizer (ASAN)

DEPENDENCIES

From the Mind_Monitor directory: devops/script/dependency_checker.sh

Tool Verify Install
Dmalloc dmalloc --version apt install libdmalloc*
Electric Fence dpkg-query --list electric-fence apt install electric-fence
Valgrind valgrind --version apt install valgrind
Memwatch ls src/memwatch.? devops/script/install_memwatch.sh
Mtrace mtrace --version Built into glibc
ASAN gcc -fsanitize=address --version apt install gcc

RUN TESTS

From the Mind_Monitor directory: devops/script/test_all.sh

TEST RESULTS

Filename Description Dmalloc Electric Fence Valgrind Memwatch Mtrace ASAN
bad_code1.c Uninit. mem โŒ๐Ÿ’ข โŒ โœ”๏ธ โŒ โŒ โœ”๏ธ๐Ÿ’ข
bad_code2.c Buffer overflow (Heap) โœ”๏ธ๐Ÿ’ข๐Ÿ’ฅ โŒ โœ”๏ธ โœ”๏ธ โŒ โœ”๏ธ
bad_code3.c Memory leak โœ”๏ธ๐Ÿ’ข โŒ โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ
bad_code4.c Invalid mem access โŒ๐Ÿ’ข โŒ๐Ÿ’ฅ โœ”๏ธ โŒ โŒ โœ”๏ธ
bad_code5.c Double free โœ”๏ธ๐Ÿ’ข๐Ÿ’ฅ โœ”๏ธ๐Ÿ’ฅ โœ”๏ธ โœ”๏ธ โŒ โœ”๏ธ
bad_code6.c Uninit. integer โŒ๐Ÿ’ข โŒ โœ”๏ธ โŒ๐Ÿ’ข โŒ โŒ
bad_code7.c Overlapping memcpy โŒ๐Ÿ’ข โŒ โŒ โŒ โŒ โœ”๏ธ
bad_code8.c Fishy malloc values โœ”๏ธ๐Ÿ’ข๐Ÿ’ฅ โœ”๏ธ๐Ÿ’ฅ โœ”๏ธ๐Ÿ’ฅ โŒ๐Ÿ’ฅ โŒ๐Ÿ’ฅ โœ”๏ธ
bad_code9.c Fishy calloc values โœ”๏ธ๐Ÿ’ข๐Ÿ’ฅ โŒ๐Ÿ’ฅ โœ”๏ธ๐Ÿ’ฅ โŒ๐Ÿ’ฅ โŒ๐Ÿ’ฅ โœ”๏ธ
bad_code10.c Multi-process memory leak โœ”๏ธ๐Ÿ’ข โŒ โŒ โœ”๏ธ โœ”๏ธ๐Ÿ’ข โŒ
bad_code11.c Multi-process double free โŒ๐Ÿ’ข โœ”๏ธ โŒ โœ”๏ธ โŒ โŒ
bad_code12.c Multi-thread memory leak โœ”๏ธ๐Ÿ’ข โŒ โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ
bad_code13.c Multi-thread double free โœ”๏ธ๐Ÿ’ข โœ”๏ธ โœ”๏ธ โœ”๏ธ โŒ๐Ÿ’ฅ โœ”๏ธ
bad_code14.c Multi-process memory leak (wait) โœ”๏ธ โŒ โŒ โœ”๏ธ โŒ โŒ
bad_code15.c Multi-process double free (wait) โŒ โœ”๏ธ โœ”๏ธ โœ”๏ธ โŒ โœ”๏ธ
bad_code16.c Buffer overflow (Stack) โŒ โŒ โŒ โŒ โŒ โœ”๏ธ

LEGEND

Emoji Meaning
๐Ÿ’ข False positive, misleading/missing results
๐Ÿ’ฅ Seg fault or core dump
โ” Test not yet executed
โœ”๏ธ Succeeded in finding the error
โŒ Failed to find the error

NOTES:

- Some ideas came from https://valgrind.org/docs/manual/mc-manual.html
- Bad Code 10 is the multi-process version of Bad Code 3
- Bad Code 11 is the multi-process version of Bad Code 5
- Bad Code 12 is the multi-thread version of Bad Code 3
- Bad Code 13 is the multi-thread version of Bad Code 5
- Bad Code 14 is Bad Code 10 with waitpid() implemented
- Bad Code 15 is Bad Code 11 with waitpid() implemented
- Turns out Mtrace's response to Bad Code 13 isn't anything above and beyond normal execution
- Bad Code 16 borrowed heavily from Bad Code 2
- *_code6_memwatch.bin and *_code16_memwatch.bin are failing to create a log file at runtime.  Theory: "...memwatch will auto-initialize on the first call to a memory function..." and neither test case calls a memory function.  I verified the binaries were linked against memwatch (e.g., `readelf -a *_code6_memwatch.bin | grep mw`).  I even tried to manually initialize memwatch with `mwInit()`, `mwDoFlush(1)`, and `mwTerm()`.

CONCLUSION

Errors Found

  • Dmalloc - 9/16
  • Electric Fence - 5/16
  • Valgrind - 11/16
  • Memwatch - 9/16
  • Mtrace - 2.5/16
  • ASAN - 12/16

NOTE: Mtrace has seemingly non-deterministic results for Bad Code 10 so it gets a ๐Ÿ’ข and a half point

Ease Of Use

On a scale of 1 to 5 (5 being the easiest to use):

  • Dmalloc - 2/5
  • Electric Fence - 3/5
  • Valgrind - 4/5
  • Memwatch - 3/5
  • Mtrace - 3/5
  • ASAN - 5/5

Readable Output

On a scale of 1 to 5 (5 being the easiest to read):

  • Dmalloc - 2/5
  • Electric Fence - 4/5
  • Valgrind - 3/5
  • Memwatch - 5/5
  • Mtrace - 5/5
  • ASAN - 4/5

Final Ranking

Ranked best to worst:

  1. ASAN (85.0%)
  2. Memwatch (72.1%)
  3. Valgrind (69.6%)
  4. Mtrace (58.5%)
  5. Electric Fence (57.1%)
  6. Dmalloc (45.4%)

mind_monitor's People

Contributors

hark130 avatar

Stargazers

Jair F Ochoa Davila avatar Minh-Triet Pham Tran avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.