[parted-devel] [PATCH] add malloc debugging using MALLOC_CHECK_

Jim Meyering jim at meyering.net
Sun Sep 2 19:14:29 UTC 2007


"Matt Davis" <mattdavis9 at gmail.com> wrote:
> On 9/2/07, Jim Meyering <jim at meyering.net> wrote:
>> I like removing all of the ifdef'd-out cruft, but not the change
>> that sets MALLOC_CHECK_ in the environment.
>> MALLOC_CHECK_ is system specific, and besides, libraries (even when
>> compiled in debug mode) shouldn't be setting environment variables.
>
> I understand your logic, and definitely agree.  After reading the man,
> yes it is system specific, and was a concern I might have considered
> originally.  Upon deeper consideration, there is no reasoning to
> assume that other architectures might implement that variable with
> completely different results.

Hi Matt,

The main reason to avoid setenv in a library is that it is not
thread-safe, which would mean that no application using the library
could be safely used in a multi-threaded application.

> So yes, it could be dangerous.
> Although if the debug mode is only implemented by developers, they can
> merely set the variable before kicking out a debug session.
> Possibly a comment suggesting that such a variable could be set for
> enhanced debugging?  Just a thought.

A comment wouldn't hurt, but imho isn't really appropriate.
Otherwise, you'd have to mention that valgrind is useful, too,
along with strace, oprofile, etc.  But none of this is specific to libparted.



More information about the parted-devel mailing list