MALLOC_CHECK - Linux

This is a discussion on MALLOC_CHECK - Linux ; One of my dependencies has changed and now my application hangs at exit time. My supervisers and cooworkers seem to think that setting MALLOC_CHECK=1 _fixes_ the problem. However, when I Google MALLOC_CHECK it seems to be more of a debugging ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: MALLOC_CHECK

  1. MALLOC_CHECK

    One of my dependencies has changed and now my application hangs at
    exit time. My supervisers and cooworkers seem to think that setting
    MALLOC_CHECK=1 _fixes_ the problem. However, when I Google
    MALLOC_CHECK it seems to be more of a debugging tool than a solution.

    I tryed to man MALLOC_CHECK
    I also tryed googling it, but only came up with scenarios.

    I need specific information on what setting this env variable to
    0,1,or 2 actually does and how it is intended to be used.

    Can anyone give some info?

  2. Re: MALLOC_CHECK

    >However, when I Google MALLOC_CHECK it seems to be more of a debugging tool than a solution.

    "info libc" then search for MALLOC_CHECK ("/MALLOC_CHECK").
    Incidentally, it is spelled MALLOC_CHECK_ with a trailing underscore.

    After exploring MALLOC_CHECK_, then you should learn about valgrind (memcheck).

    --

  3. Re: MALLOC_CHECK

    Christopher wrote:

    > However, when I Google MALLOC_CHECK it seems to be more of a
    > debugging tool than a solution.


    Correct.

    http://www.kernel.org/doc/man-pages/.../malloc.3.html

    Recent versions of glibc (2.x) include a malloc() implementation which
    is tunable via environment variables. When MALLOC_CHECK_ is set, a
    special (less efficient) implementation is used which is designed to be
    tolerant against simple errors, such as double calls of free() with the
    same argument, or overruns of a single byte (off-by-one bugs). Not all
    such errors can be protected against, however, and memory leaks can
    result. If MALLOC_CHECK_ is set to 0, any detected heap corruption is
    silently ignored; if set to 1, a diagnostic message is printed on
    stderr; if set to 2, abort(3) is called immediately; if set to 3, a
    diagnostic message is printed on stderr and the program is aborted.
    Using a non-zero MALLOC_CHECK_ value can be useful because otherwise a
    crash may happen much later, and the true cause for the problem is then
    very hard to track down.

+ Reply to Thread