libmicrohttpd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [libmicrohttpd] Memory leak?


From: Erik Slagter
Subject: Re: [libmicrohttpd] Memory leak?
Date: Mon, 01 Nov 2010 16:03:33 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.9) Gecko/20100921 Fedora/3.1.4-1.fc13 Thunderbird/3.1.4 ThunderBrowse/3.3.2

Hi Christian,

Based on your code, I can clearly see that the callback is called, but
obviously with the wrong address. However, the MHD code internally clearly
uses the right address, so the best explanation for the difference would be
some kind of memory corruption going on in between.  Have you tried valgrind
on your code?  Again, if you can produce a stand-alone *compiling* example
where the issue still arises, I'll be happy to take another look, but so far
this seems to be most likely a bug in the rest of your C++ code.  The way you
use the API (from what I can see) seems to be fine.

It's interesting that you mention valgrind, because that is the tool I found the memory leak with in the first place. So yes, the program has been running under valgrind control, with almost all options enabled. After running for a few hours, valgrinds concludes that a few little blocks of memory are lost inside ncurses (so out of my control) and that a huge pile of memory is lost that is allocated inside the access_handler_callback, allocated exactly at this line:

ConnectionData * ncd = new(ConnectionData)

And that is exactly the memory that is not free'd because of "wrong pointer" problem.

Valgrind does not mention other memory loss or memory corruption.

It strikes me that the pointer I'm receiving in the completed callback seems to be a valid pointer; it's address is very similar to the address that's actually allocated. Also the pointer always points to a null pointer, which suggests the pointer is allocated as should be, no stray pointer.

To me it looks like libmicrohttpd allocates a new pointer at some point while discarding the current pointer. I haven't had a look at the code, so this may be uterly nonsense I'm talking.

My planning is to make very stripped down version of the program, test that, and if the problem persists, I'll post the source.

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]