Memory not freed at exit ?

Aron Szabo <aron-Iv/[email protected]>
Newsgroups gmane.comp.web.fastcgi.devel
Message-ID <[email protected]>
Hi!

While debugging my app with valgrind I noticed, that memory is not being 
freed after FCGX_Init():

==10496== 768 bytes in 1 blocks are still reachable in loss record 6 of 7
==10496==    at 0x4C278AE: malloc (vg_replace_malloc.c:207)
==10496==    by 0x5190A80: OS_LibInit (in /usr/lib/libfcgi.so.0.0.0)
==10496==    by 0x518DC6B: FCGX_Init (in /usr/lib/libfcgi.so.0.0.0)
==10496==    by 0x40424B: main (bitp_web.c:427)

OS_LibInit is allocating memory (asyncIoTable pointer).

The memory should be freed by OS_LibShutdown, but that function is not 
called anywhere in the library.

I noticed cgi-fcgi.c has a cleanup routine defined:

static void FCGIexit(int exitCode)
{
    if(appServerSock != -1) {
        OS_Close(appServerSock);
    appServerSock = -1;
    }
    OS_LibShutdown();
    exit(exitCode);
}

#undef exit
#define exit FCGIexit

Of course it's being freed after the program exited, so it's not 
critical, but it's not right.

Maybe cleanup should be defined and be added to the documentation.
#define FCGX_Cleanup OS_LibShutdown();

Yours,
Aron
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.