On 15 November 2010 12:56, WAROQUIERS Philippe
<[email protected]> wrote:
>>int main(void)
>>{
>>    char buf[1000]  = malloc(1000;
>>    buf[0] = 0;
>>    return 0;
>>}
> The above program is slightly strange (does not compile here).
>
> But a slightly updated version does also not report a leak.

My bad, should have double checked my message first. That was a typo
that is an obvious syntax error.
>
> This is explained by the fact that valgrind does the equivalent of
> an "optimistic garbage collection" to find leaks.
> So, it is enough that somewhere in memory or in a register, there is
> 4 bytes (or 8 bytes on a 64 bits) that happens to "point" at an
> allocated (not freed) block to have valgrind considering it still
> reached.
>
> In my case, it is enough to add another line
>   buf = malloc (1000);
> to have the first block being reported as leaked.

Yes you are right. Since a reference to the allocated memory didn't
lose scope valgrind wouldn't report a leak here.
However, note that the valgrind report in the opening message show
that valgrind detected 0 allocation, whereas it should have detected
an allocation of 1000 bytes.

This might me somewhat related to the error messages on startup,
complaining about unrecognized or non-existant debug information.

My guess is that somehow valgrind doesn't find the replacement malloc,
etc on its own libraries due to those strange debug info errors and
thus does not redirect the programs memory allocations into the
instrumentation functions, which results in memory checkes not
hapening at all. If such theory is correct, what causes it or how to
solve it is beyond my reach, I'm afraid :(

Thanks
--
tone

------------------------------------------------------------------------------
Centralized Desktop Delivery: Dell and VMware Reference Architecture
Simplifying enterprise desktop deployment and management using
Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
client virtualization framework. Read more!
http://p.sf.net/sfu/dell-eql-dev2dev
_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to