Re: Possibly Lost Error

Paul Floyd via Valgrind-users <[email protected]> Wed, 13 Nov 2024 08:10:37 +0100
Newsgroups gmane.comp.debugging.valgrind
Message-ID <[email protected]>

On 12-11-24 22:22, William Chan (BLOOMBERG/ 919 3RD A) wrote:
> Hi,
> 
> I have a program that induces a possibly lost warning via an interior 
> pointer but I deallocate the pointer properly. Is Valgrind supposed to 
> be able to know that an interior pointer is freed? I'm trying to 
> determine whether or not my possibly lost warning is safe to ignore.

Unless something has gone wrong Memcheck redirects and records all calls 
to allocation and deallocation functions. "Interior pointers" are never 
freed, only the original pointers. Passing an interior pointer to 
operator delete or free would result in an "Invalid free() / delete / 
delete[] / realloc()" error.

I think that "possibly lost" is a rather misleading name. There's no 
doubt that the memory is lost. The only doubt is to whether it is really 
a "definite" leak or a "still reachable" (via the interior pointer) one.

See this item on SO for a C++ example.
https://stackoverflow.com/questions/17630892/is-there-a-simple-example-of-false-positive-valgrind-possibly-lost-report

We need more details in order to be sure. Can you share a small example?

A+
Paul