delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2013/08/19/08:36:28

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:to:subject:message-id:reply-to
:references:mime-version:content-type:in-reply-to; q=dns; s=
default; b=fQ4jeB8z69LazRxF0RI84oluHA23ZBgQJ3DEdNo0+GnCkDAVBjMTT
4sdKjk+jhS97IjzKbHJS5KQsGfK6OAAfzBVx+ktVATPO/38epZh9KHtdCHziCf40
SFKgVzGER85PvRD1FOAqOypXkfwFrzHFOwQdmOX7sXPqqrJfbqGUYc=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:to:subject:message-id:reply-to
:references:mime-version:content-type:in-reply-to; s=default;
bh=1reLspRQam6C5UfvJ//NwskqqnM=; b=RLWCTA3XSROq3dcQAmxF39Izn8XK
RPb2J2b/2LMQaDQpv8EOqjBayoBb7zk4qBq/09MWGyq7Nlg5wzJl6Mx8DVRK9CmD
3AZGe3MBr255Q8F6rQZQemJsxL3poroBr1qAsmQbDlNz3G1dej9U3A3MEKOKXfGc
tCWJ2j5RrLIwNb8=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
X-Spam-SWARE-Status: No, score=-4.4 required=5.0 tests=AWL,BAYES_00,KHOP_PGP_SIGNED autolearn=ham version=3.3.2
Date: Mon, 19 Aug 2013 14:36:12 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Stack size on 64-bit Cygwin
Message-ID: <20130819123612.GA31248@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <520E905A DOT 409 AT cornell DOT edu> <20130819093242 DOT GB18757 AT calimero DOT vinschen DOT de> <5211F83A DOT 30901 AT cs DOT utoronto DOT ca> <5211FBB6 DOT 6070108 AT cs DOT utoronto DOT ca> <20130819113919 DOT GA29385 AT calimero DOT vinschen DOT de> <521204EA DOT 6020607 AT cs DOT utoronto DOT ca>
MIME-Version: 1.0
In-Reply-To: <521204EA.6020607@cs.utoronto.ca>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Virus-Found: No

--wac7ysb48OaltWcw
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Aug 19 07:43, Ryan Johnson wrote:
> On 19/08/2013 7:39 AM, Corinna Vinschen wrote:
> >On Aug 19 07:04, Ryan Johnson wrote:
> >>On 19/08/2013 6:49 AM, Ryan Johnson wrote:
> >>>One thing I don't understand, though: shouldn't a stack overflow
> >>>normally manifest as a seg fault when trying to access the invalid
> >>>addresses, rather than silent memory corruption?
> >That would be helpful.
> >
> >>>However, /proc/pid/maps for emacs shows:
> >>>>00010000-00020000 rw-s 00000000 0000:0000 0
> >>>>[win heap 1 default shared]
> >>>>00020000-00030000 rw-s 00000000 0000:0000 0 [win heap 2 default share=
d]
> >>>>00030000-001E4000 =3D=3D=3Dp 00000000 0000:0000 0 [stack (tid 4896)]
> >>>>001E4000-001E6000 rw-g 001B4000 0000:0000 0 [stack (tid 4896)]
> >>>>001E6000-00230000 rw-p 001B6000 0000:0000 0 [stack (tid 4896)]
> >>>GDB reports that thread 4896 is the main thread... so I guess
> >>>Windows doesn't reserve a red zone around its stack, but instead
> >>>chooses to place the main thread stack right next to the
> >>>fully-mapped global shared heap to maximize the potential for Fun?
> >Right.  I have no idea what the two shared mem regions preceeding the
> >stack are good for, though.
> >
> >
> >>Some googling turns up
> >>http://comments.gmane.org/gmane.comp.java.openjdk.hotspot.runtime.devel=
/7706
> >>>Windows only uses reserved but only partially committed memory for its=
 stacks. In order to detect when to
> >>>commit more stack, it installs  a one-shot guard page (btw the same ty=
pe of guard page that is used for the
> >>>hotspot yellow and red zone) right at the edge of the currently commit=
ed stack zone. When a thread accesses
> >>>this guard page an exception is thrown which Windows catches internall=
y, commits more stack and
> >>>re-establishes the one-shot guard page at the new edge of the commited=
 zone. When Windows detects such an
> >>>exception inside the _last 4 pages_ of a stack (I couldn't find any do=
cumentation for that on MSDN, I found
> >>>this value from manually testing on several Windows machines with 4k s=
tack pages) it throws a STACK_OVERFLOW_EXCEPTION.
> >>So maybe emacs just had the incredibly bad luck to alloca() a large
> >>buffer right at end-of-stack and then somehow managed to skip over
> >>the 4 guard pages when accessing it?
> >That's unlikely since alloca is designed to probe the stack in 4K
> >steps.  And STATUS_STACK_OVERFLOW is translated to a SEGV by Cygwin's
> >exception handler.
> ... and yet somehow emacs managed to get around that protection
> (unintentially), leading to all that fun over the last week. What
> went wrong?

Good question.  I don't know.


Corinna

--=20
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

--wac7ysb48OaltWcw
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (GNU/Linux)

iQIcBAEBAgAGBQJSEhE8AAoJEPU2Bp2uRE+gDloQAKN26ch3OhVC9LYnD3PJLvqV
uiFvTOpuSSBQtzf086G0EV3A+0dFbBCQMerRIhjFBDFw7But9KJwdLPasF+L/VOn
vpY6n5qVSVGH4qphe3YG6ee2AmPlGkZzqgkfva7GbdLtIX9agYx1+aB0jEXPtqN8
7UMRyQA3jQDWkO9xc68xQ/2rp+vKHr3is3IsuManLe9SSUkIFR1sIlpANY/YeeOk
5msydIlggk55YMUorTZ6W+/IuCjcwRxOPT1fLyAYobTsLx20IPChpNNzPuZnz+a7
LAkmNSP5ZL9+yo0Y/idMryGugEwA7FXB1w856AaHRZnepuZ5ya0tHY9nJgj/7mQ7
b1cuyIdsQbyw/C1un5DaeFPpGbUIQyYPukl3AHIM9DZzfOC726UCC+EFicSZ66uv
JEk5nBhwlZEovpKlTeS5yVjmBkPl+DV8TIAXDlR24FWR7FdbmhIHrDkHiz0hD3Pq
ivIfnbdekLyh26ETqI3O63NkGc++3xhdopuLswIy4L9exHRQZ+hqBgd7zvn1XcaV
kMVQtDX8zCuXSMkGp0U7/1lsaa2aoSrhqY0h0EJe8KdTHUEHj+t8bSv6f6MtjlDq
v11iXLYG3CS0e2odfFiAmKK+zsqfy8PQUaJ4nmf+DkztbeNOJ6ksq0b7yEkFNJIa
+qBKT8ej5nKcmhy6io13
=Y0z0
-----END PGP SIGNATURE-----

--wac7ysb48OaltWcw--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019