From: cgf AT cygnus DOT com (Christopher Faylor) Subject: Re: Memory leaks in cygwin.dll 26 Aug 1998 11:42:08 -0700 Message-ID: <19980826142247.A31674.cygnus.cygwin32.developers@cygnus.com> References: <01BDD130 DOT DB72EF60 AT sos> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii To: Sergey Okhapkin , "cygwin32-developers AT cygnus DOT com" On Wed, Aug 26, 1998 at 08:33:59PM +0400, Sergey Okhapkin wrote: >Christopher Faylor wrote: >> I've committed these changes (and the revision sent in subsequent email). >> >> Thank you for submitting them. >> > >With these changes bash traps on starting a process when tty support is >enabled... Dup2 call forks unix_path_name_ pointer! What about to replace >this pointer with a static array? I've actually fixed this in the experimental stuff that I've been working on. In the interim, does this solve the problem? Index: ChangeLog =================================================================== RCS file: /cvs/cvsfiles/devo/winsup/ChangeLog,v retrieving revision 1.538 diff -u -p -r1.538 ChangeLog --- ChangeLog 1998/08/26 16:19:46 1.538 +++ ChangeLog 1998/08/26 18:20:41 @@ -1,3 +1,11 @@ +Wed Aug 26 14:15:22 1998 Christopher Faylor + + * fhandler.h (fhandler_base): Make set_name() public and implement + clear_name() to accomodate dup2. + * hinfo.cc (dup2): Previous change exposed problem with dup2. + Same unix_path_name_ ptr was being used in two separate fds. + Fix this. + Wed Aug 26 12:10:27 1998 Christopher Faylor patch from sos AT prospect DOT com DOT ru (Sergey Okhapkin): Index: fhandler.h =================================================================== RCS file: /cvs/cvsfiles/devo/winsup/fhandler.h,v retrieving revision 1.53 diff -u -p -r1.53 fhandler.h --- fhandler.h 1998/07/08 19:14:13 1.53 +++ fhandler.h 1998/08/26 18:20:41 @@ -73,8 +73,6 @@ class fhandler_base /* File open flags from open (void) and fcntl (void) calls */ int openflags_; - void set_name (const char *); - protected: char symlink_p_; @@ -107,7 +105,10 @@ public: void set_close_on_exec (char val) { close_exec_p_ = val; } char get_close_on_exec (void) { return close_exec_p_; } + void clear_name () {unix_path_name_ = NULL; } const char *get_name (void) { return unix_path_name_; } + void set_name (const char *); + unsigned long get_namehash (void) { return namehash_; } /* Potentially overridden virtual functions. */ Index: hinfo.cc =================================================================== RCS file: /cvs/cvsfiles/devo/winsup/hinfo.cc,v retrieving revision 1.52 diff -u -p -r1.52 hinfo.cc --- hinfo.cc 1998/08/17 21:05:00 1.52 +++ hinfo.cc 1998/08/26 18:20:41 @@ -352,6 +352,8 @@ hinfo_vec::dup2 (int oldfd, int newfd) vec[newfd].h = (fhandler_base *) &vec[newfd].item; vec[newfd].item = vec[oldfd].item; + vec[newfd].h->clear_name (); + vec[newfd].h->set_name (vec[oldfd].h->get_name ()); if (vec[oldfd].h->dup (vec[newfd].h) != 0) return -1;