memory leak in cygheap

egor duda deo@logos-m.ru
Thu Sep 27 09:53:00 GMT 2001


Hi!

  this simple program:

#include <sys/types.h>
#include <dirent.h>

int main ()
{
  DIR* x = 0;
  for (;;)
    {
      x = opendir ("/");
      closedir (x);
    }
  return 0;
}

leaks memory and eventually dies with "can't allocate cygwin heap"
error message.

attached patch fix this.
do we need this "no free names" logic at all? the only suspicious
place is fhandler_disk_file::open () where we were storing pointer to
real_path's win32_path, so if it was changing later we were staying in
sync with those changes. but i can't see why it may change after open
is called, so making duplicate looks safe for me. Comments?

egor.            mailto:deo@logos-m.ru icq 5165414 fidonet 2:5020/496.19
cygheap-leak.diff
cygheap-leak.ChangeLog

-------------- next part --------------
2001-09-27  Egor Duda  <deo@logos-m.ru>

	* fhandler.h (class fhandler_base::unset_name): New function.
	* fhandler.cc (fhandler_base::unset_name): Deallocate cygheap
	memory used for file names and unset the names.
	(fhandler_base::set_name): Use it. Eliminate no_free_names ()
	logic to avoid memory leaks.
	(fhandler_base::~fhandler_base): Ditto.
	(fhandler_disk_file::fhandler_disk_file): Eliminate no_free_names ()
	logic.
	(fhandler_disk_file::open): Ditto. Always allocate space for
	win32_path_name on cygheap.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cygheap-leak.diff
Type: text/x-diff
Size: 2766 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20010927/30933e1c/attachment.bin>


More information about the Cygwin-patches mailing list