Thanks for the detective work and the fix Scott!
Kudos,
Alfred
On Fri, 4 Apr 2003, Scott Goodwin wrote:
> Problem Report on nscgi Memory Leak:
>
> !!! THIS IS A MAJOR BUG FOR ANYONE RUNNING CGI SCRIPTS IN AOLSERVER 3.x
> !!!
>
> This bug exists in released versions of AOLserver 3.x inclusive of
> AOLserver 3.5.1 all the way back to AOLserver 3.0. Any past or current
> reports of AOLserver 3.x growing in size over time should be
> re-examined with this bug in mind.
>
> The leak has been fixed in the CVS tree for AOLserver 3 (3.5 branch).
> AOLserver 4.x's nscgi module is *not* affected by this problem.
>
> If you wish to fix the problem in your current version of AOLserver
> 3.x, edit the aolserver/nscgi/nscgi.c file, find the CgiExec function,
> and delete the call to "Ns_DStringInit(dsPtr);". Then recompile your
> server. Here is what it looks like in context:
>
> /*
> * Set all the CGI specified variables.
> */
>
> Ns_DStringInit(dsPtr);
> SetUpdate(cgiPtr->env, "SCRIPT_NAME", cgiPtr->name);
> if (cgiPtr->pathinfo != NULL && *cgiPtr->pathinfo != '\0') {
> Ns_DString tmp;
> ...
>
> Notes:
>
> The leak occurred in the CgiExec function of nscgi.c. The nscgi.c file
> defines a function called CgiDs which does an Ns_DStringPop to obtain a
> dstring, and then uses that dstring's 'addr' member to maintain a
> linked-list of dstrings that nscgi is currently using. At the end of
> the CGI process, the CgiFree function is called to walk through that
> linked-list and perform an Ns_DStringPush on each of the dstrings to
> put them back into the thread's local dstring pool.
>
> The memory leak was caused when Ns_DStringInit was called and passed a
> dstring obtained by a previous call to CgiDs. The Ns_DStringInit call
> broke the linked-lisk because it NULL'd the addr member of the dstring,
> which had been pointing to the next dstring in the linked-list. The
> effect was that every invocation of of a CGI script was causing
> dstrings to be left dangling in memory.
>
> This problem *does not* exist in AOLserver 4.x because nscgi no longer
> uses Ns_DString's addr member to maintain the linked list.
>
>
>
> /s.
>
>
> --
> AOLserver - http://www.aolserver.com/
> To Remove yourself from this list: http://www.aolserver.com/listserv.html
> List information and options: http://listserv.aol.com/
>
--
AOLserver - http://www.aolserver.com/
To Remove yourself from this list: http://www.aolserver.com/listserv.html
List information and options: http://listserv.aol.com/