delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2011/12/09/12:07:30

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-7.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS
X-Spam-Check-By: sourceware.org
Message-ID: <4EE24037.1000105@redhat.com>
Date: Fri, 09 Dec 2011 10:07:03 -0700
From: Eric Blake <eblake AT redhat DOT com>
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111115 Thunderbird/8.0
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: gcc-4.5.3 segfaults wrt alloca
References: <20111209105801 DOT GA10388 AT po8371> <4EE22156 DOT 4080402 AT cs DOT utoronto DOT ca>
In-Reply-To: <4EE22156.4080402@cs.utoronto.ca>
OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg
X-IsSubscribed: yes
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

--------------enig6E9A03676933CFD92790B1F0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

On 12/09/2011 07:55 AM, Ryan Johnson wrote:
> On 09/12/2011 5:58 AM, Denis Excoffier wrote:
>> I use the latest packages and cygwin snapshots. The problem described
>> below began several snapshots in the past, around beginning of December.
>>
>> The following program, with static allocation of a reasonable amount
>> of data, segfaults, maybe in alloca(). With a smaller size
>> (eg 10000) it's ok. With new/malloc (even with 100 times more) it's
>> ok. With C or C++. 100% reproducible.
>>    unsigned int const SIZE =3D 689471;
>>    int foo[SIZE];
> Reasonable? You're trying to stack-allocate 2.5MB of data. Don't do that
> -- stack sizes are 2MB or less in most operating systems. Besides, doing
> anything useful with a buffer that size would completely drown out the
> overhead of calling malloc.

Not only that, but stack allocating more than 64k in a single function
is a recipe for bypassing the guard page and causing windows to silently
quit your program, rather than letting cygwin catch the guard page
access and convert it to normal SIGSEGV handling.  To be portable to all
OS, you should never stack allocate more than 4k in a single function.

--=20
Eric Blake   eblake AT redhat DOT com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


--------------enig6E9A03676933CFD92790B1F0
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Public key at http://people.redhat.com/eblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBCAAGBQJO4kA3AAoJEKeha0olJ0NqorsIAIUzwqz2SGZSwmO0yiuDCUco
sCUhLLW6Cbpt44ULA8xRdnnc9WqGeq+HcaO7vxNxcizaRT1b6M4ZblNcb3f4EKsW
Qo9w0uzwICtaVCiPc5ZfTv0bjdmZD+IFtJD3umzjyPxeuHLiR7JapS2KeLzGCmsM
6z0ydfN9Ms7GZexAVQnv4rIb6KU8bYmYorAjiUqTfE/V0l9up54vppY4DTO+Nz46
9Rtwn02Mx99PH0XjHlpJlzPmPnUS7n9rojaGtH3bBzsqOnn0aRASinHWTgy8u4Fh
aWsX9LMmZJR59RG/9cLk39fXT4nNjrj8sEvPz8WOrM7JsKamHCBktfJ/WlXDuj4=
=TuMd
-----END PGP SIGNATURE-----

--------------enig6E9A03676933CFD92790B1F0--

- Raw text -


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