X-Recipient: archive-cygwin@delorie.com
X-SWARE-Spam-Status: No, hits=-1.8 required=5.0	tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,T_TO_NO_BRKTS_FREEMAIL
X-Spam-Check-By: sourceware.org
Message-ID: <4C8E7CD2.6020006@gmail.com>
Date: Mon, 13 Sep 2010 20:34:42 +0100
From: Dave Korn <dave.korn.cygwin@gmail.com>
User-Agent: Thunderbird 2.0.0.17 (Windows/20080914)
MIME-Version: 1.0
To: cygwin@cygwin.com
Subject: Re: Cygwin instabilities
References: <AANLkTim+hU+Cg6_J83B_h9VHsL8wiC4Xh7TbcwzjSjkW@mail.gmail.com> <4C8E3A4B.8030909@cygwin.com> <AANLkTimX-AztuJvS-RG+bZqWCVN7tEdQXs6Ogw_fCZC5@mail.gmail.com> <20100913173648.15137e2d0sfh16o0@webmail.df.eu> <AANLkTi==Dok1uNspQumrPZmm3dEmrt8RN9cjLvEhiiC0@mail.gmail.com> <20100913163523.GA25859@ednor.casa.cgf.cx>
In-Reply-To: <20100913163523.GA25859@ednor.casa.cgf.cx>
Content-Type: multipart/mixed; boundary="------------050809060001020500050601"
X-IsSubscribed: yes
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

--------------050809060001020500050601
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

On 13/09/2010 17:35, Christopher Faylor wrote:

> You seem to be approaching this problem as if people will say "Ah!
> Stability issues! Right.  Well, ok, here's what you need to know."
> 
> If we knew of stability issues they would be fixed.

  Well, I know of one, but haven't had time to fix it yet, so I keep this hack
in my local builds.  Can't run "make check -jN" without it, but even then it
sometimes locks up.

  The problem I've run into is that on a heavily loaded system, a pinfo struct
can get truncated into a redirector in between the time a syscall checks the
process_state (using ISSTATE or NOTSTATE) and the time it subsequently
attempts to access a pinfo member which it hoped to guard by that check.

  I have a bad feeling that the only way to totally resolve this is going to
be adding lots of locking or mutexing around pinfo calls, which is almost
bound to have performance implications :-(

    cheers,
      DaveK


--------------050809060001020500050601
Content-Type: text/x-c;
 name="pinfo-fix.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="pinfo-fix.diff"

--- src.clean/winsup/cygwin/pinfo.h	2010-09-01 22:06:36.000000000 +0100
+++ src/winsup/cygwin/pinfo.h	2010-09-06 20:36:17.062500000 +0100
@@ -51,8 +51,6 @@ public:
 
   DWORD exitcode;	/* set when process exits */
 
-#define PINFO_REDIR_SIZE ((char *) &myself.procinfo->exitcode - (char *) myself.procinfo)
-
   /* > 0 if started by a cygwin process */
   DWORD cygstarted;
 
@@ -64,9 +62,6 @@ public:
     signals.  */
   DWORD dwProcessId;
 
-  /* Used to spawn a child for fork(), among other things. */
-  WCHAR progname[NT_MAX_PATH];
-
   /* User information.
      The information is derived from the GetUserName system call,
      with the name looked up in /etc/passwd and assigned a default value
@@ -121,6 +116,12 @@ public:
   HANDLE wr_proc_pipe;
   DWORD wr_proc_pipe_owner;
   friend class pinfo;
+
+  /* Used to spawn a child for fork(), among other things. */
+  WCHAR progname[NT_MAX_PATH];
+  /* Truncate it after execed process exits. */
+#define PINFO_REDIR_SIZE ((char *) &myself.procinfo->progname[0] - (char *) myself.procinfo)
+
 };
 
 DWORD WINAPI commune_process (void *);


--------------050809060001020500050601
Content-Type: text/plain; charset=us-ascii

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
--------------050809060001020500050601--
