Git Product home page Git Product logo

bleak's Introduction

1. What it does

   bleak is a malloc wrapper that checks for leaks. When print_leaks() is
   called it will print out all the leaked addresses as well as a backtrace
   showing where the memory was allocated from. bleak is thread-safe.

2. How it does it

   bleak keeps a table of every allocation. When print_leaks() is called, it
   searches all possible addresses, seeing if there is a reference to that
   location. If there is not, it marks that allocation as a leak.

   It figures out what the possible addresses are by reading /proc/pid/maps.
   This means that bleak most likely only works on Linux.

   Because it is searching for an address that points to the allocated space,
   it is affected by things like pointer logic and luck. For example, if you
   have a pointer pointing to an allocated block, and increment the pointer to
   write to the byte after, the pointer is no longer pointing at the allocated
   block, and this will be considered a leak. Also if there is a place in
   memory, say in a binary data buffer, with the same contents as the address,
   this will be considered a pointer to the address, and so not a leak, even if
   it only "points" there through dumb luck.

3. How to compile it

   There is a Makefile included that should build bleak without any problems.
   bleak depends on pthreads, libdl, and bfd. bfd in turn depends on libiberty.
   Some systems may not need -liberty to be pased to the linker, but shouldn't
   complain when it is.

4. How to use it

   Link your program against libbleak.so. You can do this either through a
   relink or by using the LD_PRELOAD environment variable. Then when you want
   to check for leaks, call print_leaks(). You can do this either by modifying
   your program or by running the program from inside gdb.

5. That's it?

   Yes. I wanted bleak to be very small and to only check for leaks. It's
   targetted at an embedded linux environment where there is only a console.
   Because it keeps track of allocations it also implicitly protects against
   double-free's. But that wasn't the goal, and if you want to check for memory
   abuse instead of memory disuse, use electric fence.

bleak's People

Contributors

warmenhoven avatar

Watchers

 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.