memory leak on dns failure?

Ming Fu <[email protected]>
Newsgroups gmane.comp.web.polipo.user
Message-ID <[email protected]>
Hi,

I found the polipo grow bigger in memory footage upon bombed with url of
non-exist dns.
Each failed dns lookup will create an atom struct with the error message.
The reference count of the atom

int
httpServerConnectionDnsHandler(int status, GethostbynameRequestPtr request)
{
    HTTPConnectionPtr connection = request->data;

    httpSetTimeout(connection, -1);

    if(status <= 0) {
        AtomPtr message;
        message = internAtomF("Host %s lookup failed: %s",
                              request->name ?
                              request->name->string : "(unknown)",
                              request->error_message ?
                              request->error_message->string :
                              pstrerror(-status));
        do_log(L_ERROR, "Host %s lookup failed: %s (%d).\n",
               request->name ?
               scrub(request->name->string) : "(unknown)",
               request->error_message ?
               request->error_message->string :
               pstrerror(-status), -status);
        connection->connecting = 0;
        if(connection->server->request)
            httpServerAbortRequest(connection->server->request, 1, 504,
                                   retainAtom(message));
        httpServerAbort(connection, 1, 502, message);
        return 1;
    }

Below are the gdb traces from polipo-20080907. I use wget to feed polipo
with url "this.url.noexist"

# export http_proxy=127.0.0.1:7070
# wget this.url.noexist

I feed it with the same bad url and see the atom reference count increase
every time.
I also tried to detach gdb from the polipo and send it a USR2 signal to see
if clean up the objects can free up the atom. It doesn't.
See the two gdb of the same process, and the kill -USR2 in between.

Any in depth explanation of what does the httpServerAbortRequest() and
httpServerAbort() do will be helpful for me to track down the root of the
problem.

Thanks
Ming

(gdb) break server.c:540
Breakpoint 1 at 0x805ec3d: file server.c, line 540.
Missing separate debuginfos, use: debuginfo-install glibc.i686
(gdb) c
Continuing.
DNS: Host not found
Host this.url.noexist lookup failed: Host not found (131072).

Breakpoint 1, httpServerConnectionDnsHandler (status=-131072,
request=0xbf9ee558)
    at server.c:541
541             connection->connecting = 0;
(gdb) print *message
$1 = {refcount = 5, next = 0x0, length = 51, string = "H"}
(gdb) printf "%s", message.string
Host this.url.noexist lookup failed: Host not found(gdb)
(gdb) c
Host this.url.noexist lookup failed: Host not foundContinuing.
DNS: Host not found
Host this.url.noexist lookup failed: Host not found (131072).

Breakpoint 1, httpServerConnectionDnsHandler (status=-131072,
request=0xbf9ee558)
    at server.c:541
541             connection->connecting = 0;
(gdb) printf "%s", message.string
Host this.url.noexist lookup failed: Host not found(gdb) printf "%s",
message.string
(gdb) printf "%s", message.string
Host this.url.noexist lookup failed: Host not found(gdb)
Host tprintf "%s", message.string
Host this.url.noexist lookup failed: Host not found(gdb) c
Host this.url.noexist lookup failed: Host not foundContinuing.
DNS: Host not found
Host this.url.noexist lookup failed: Host not found (131072).

Breakpoint 1, httpServerConnectionDnsHandler (status=-131072,
request=0xbf9ee558)
    at server.c:541
541             connection->connecting = 0;
(gdb) print *message
$2 = {refcount = 7, next = 0x0, length = 51, string = "H"}
(gdb) printf "%s", message.string
Host this.url.noexist lookup failed: Host not found(gdb) c
Continuing.
DNS: Host not found
Host this.url.noexist lookup failed: Host not found (131072).

Breakpoint 1, httpServerConnectionDnsHandler (status=-131072,
request=0xbf9ee558)
    at server.c:541
541             connection->connecting = 0;
(gdb) print *message
$3 = {refcount = 8, next = 0x0, length = 51, string = "H"}
(gdb) printf "%s", message.string
Host this.url.noexist lookup failed: Host not found(gdb)
(gdb) c
Host this.url.noexist lookup failed: Host not foundContinuing.
DNS: Host not found
Host this.url.noexist lookup failed: Host not found (131072).

Breakpoint 1, httpServerConnectionDnsHandler (status=-131072,
request=0xbf9ee558)
    at server.c:541
541             connection->connecting = 0;
(gdb) print *message
$4 = {refcount = 9, next = 0x0, length = 51, string = "H"}
(gdb) printf "%s", message.string
Host this.url.noexist lookup failed: Host not found(gdb) c
Continuing.
------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.