This is the mail archive of the
mailing list for the Cygwin project.
RE: Cygwin Shell Fails to Start when Enabling High Address
- From: Benjamin Cao <becao at progress dot com>
- To: "cygwin at cygwin dot com" <cygwin at cygwin dot com>
- Date: Tue, 28 Jul 2015 17:26:03 +0000
- Subject: RE: Cygwin Shell Fails to Start when Enabling High Address
- Authentication-results: sourceware.org; auth=none
- References: <a0044cbe3ab747048d7246806562f509 at ntmaexbe03 dot bedford dot progress dot com> <20150224213422 dot GS437 at calimero dot vinschen dot de> <56960a5bb2344de09875b4d117bf19b4 at ntmaexbe03 dot bedford dot progress dot com> <20150727201519 dot GB12449 at calimero dot vinschen dot de>
When I start Cygwin, with the AllocationPreference registry enable for VirtualAlloc, the shell immediate closes. I get the below error.
2 [main] sh 5240 c:\cygwin\bin\sh.exe: *** fatal error - internal error reading the windows environment - too many environment variables?
I guess you have answered the question to when we could get our testing running on Cygwin, but I'm unable to get to that point if the shell cannot start. Any advice on what I'm seeing now?
From: email@example.com [mailto:firstname.lastname@example.org] On Behalf Of Corinna Vinschen
Sent: Monday, July 27, 2015 4:15 PM
Subject: Re: Cygwin Shell Fails to Start when Enabling High Address
On Jul 27 18:41, Benjamin Cao wrote:
> We are revisiting our issue with running Cygwin by enabling the
> AllocationPreference registry to run in high address. Weâre hoping
> some clarification from our colleague could help shed some light on
> our situation.
> âA major part of the work we did in the NT64 port was making sure that
> 64-bit pointers are not truncated to 32 bits. Most of the time you can
> get away with a truncated pointer because the address is in the lower
> 4GB of the address space and the upper 32 bits of the 64-bit pointer
> are not used. The AllocationPreference=0x100000 setting forces memory
> allocations to use addresses above 4GB so that the upper 32 bits of
> 64-bit pointers are used. This can uncover bugs that would otherwise
> not be found until a process has used a lot of memory. Rather than
> stressing the machines by having every test allocate a ton of memory
> we can use this setting to accomplish the same thing. This testing has
> found several bugs in existing code and it helps guard against
> developers making the mistake of truncating pointers in new code.â
> This is a setting supported by Microsoft (see below).
> The AllocationPreference registry setting is documented on Microsoftâs website: https://msdn.microsoft.com/en-us/library/windows/hardware/dn613975(v=vs.85).aspx
> Usually, VirtualAlloc returns virtual addresses in low -> high order.
> So, unless your process allocates a lot of memory or it has a very
> fragmented virtual address space, it will never get back very high
> addresses. This is possibly hiding bugs related to high addresses.
> There is a simple way to force allocations in top -> down order in
> Windows Server 2003, Datacenter Edition and Enterprise Edition
> operating systems and this can reveal important bugs.
> Itâs important that we have this registry enabled for our work and if
> your answer is still the same as before, will getting a support
> contract enable us to get this capability?
So you're talking about a 64 bit application? You didn't say so in your OP.
Anyway, I'm very much puzzled.
Either your application is a native Windows, non-Cygwin application using VirtualAlloc. Then it doesn't matter how Cygwin handles memory for it's own processes to you since the memory allocations in your process have nothing to do with Cygwin's allocation style.
Or it's a POSIX application ported to Cygwin. In this case you shouldn't use VirtualAlloc but malloc or mmap, and the way memory gets allocated is not in your realm, but in Cygwin's. Also, on 64 bit Cygwin all memory (except thread stacks) is allocated beyond 0x1:0000000 anyway. On 32 bit with 3gb/4gt setting or on WOW64, the heap used for malloc allocations < 256K is beyond 0x80000000 and mmap s are allocated top down, so they start beyond 0x80000000 as well.
So a Cygwin application is either high memory clean or it will crash.
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com