X-Recipient: archive-cygwin@delorie.com
X-Spam-Check-By: sourceware.org
Date: Wed, 29 Jul 2009 19:25:22 -0400
From: Christopher Faylor <cgf-use-the-mailinglist-please@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: Emacs can't start-process more than 30~40 processes
Message-ID: <20090729232522.GC13645@ednor.casa.cgf.cx>
Reply-To: cygwin@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
References: <83iqhlbgoc.fsf@gmail.com>  <4A6727A8.2090905@cornell.edu>  <83iqhkur2h.fsf@gmail.com>  <834osy98jo.fsf_-_@gmail.com>  <83tz0xtt6c.fsf@gmail.com>  <20090729023256.GC11458@ednor.casa.cgf.cx>  <838wi8vt9v.fsf@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <838wi8vt9v.fsf@gmail.com>
User-Agent: Mutt/1.5.20 (2009-06-14)
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@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

On Wed, Jul 29, 2009 at 03:32:28PM +0800, Haojun Bao wrote:
>Christopher Faylor <cgf-use-the-mailinglist-please@cygwin.com> writes:
>
>> On Tue, Jul 28, 2009 at 10:52:44AM +0800, Haojun Bao wrote:
>>>I have debugged it again, and I think I have more clue. I have read the
>>>how-cygheap-works.txt, and this might be a known problem.
>>>
>>>It's because the cygheap space has been used up. With Procexp, I can see
>>>cygwin1.dll is based 0x61000000, with size 0x300000 (3M). When segfault
>>>is about to happen, cygheap_max is 0x6164e924, and the _csbrk is called
>>>with a increase of 
>>>    (gdb) p sbs
>>>    $16 = 65544
>>>This will increase cyghead to 0x6165e92c, but from Proxexp I can see
>>>cygncurses-9.dll is based at 0x61650000.
>>>
>>>Besides, this code snippet from pipe.cc fhandler_pipe::create didn't
>>>check for NULL pointer, and directly caused the segfault.
>>>
>>>      fhs[0] = (fhandler_pipe *) build_fh_dev (*piper_dev);
>>>      fhs[1] = (fhandler_pipe *) build_fh_dev (*pipew_dev);
>>>
>>>//bhj: we should check NULL here.
>>
>> Not necessarily.  We don't expect these functions to return NULL.  It
>> would be interesting to know how many fds are open at this point.  If it
>> is a large number then maybe we have to start enforcing an fd max.  If
>> it is a "small" number then something is wrong and we're allocating too
>> much of the cygheap.  The cygheap was always supposed to be relatively
>> small.  Maybe we're abusing it too much in 1.7.
>
>There are quite some fds. In start-process, emacs will allocate 1 PTY
>and 1 pipe for each process it starts.

Yes, I assumed that there were a bunch of fds but I was looking for an
exact number rather than "quite some".  I can't give exact details about
how to find the number now but I thought that since you were looking at
the code it wouldn't be too hard to figure this value out.

Anyway, Corinna has a stopgap fix for this which will probably show up
in a 1.7.0-* release sometime soon.

cgf

--
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

