public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: Cygwin Shell Fails to Start when Enabling High Address
Date: Mon, 27 Jul 2015 20:15:00 -0000	[thread overview]
Message-ID: <20150727201519.GB12449@calimero.vinschen.de> (raw)
In-Reply-To: <56960a5bb2344de09875b4d117bf19b4@ntmaexbe03.bedford.progress.com>

[-- Attachment #1: Type: text/plain, Size: 3143 bytes --]

On Jul 27 18:41, Benjamin Cao wrote:
> Hi,
> 
> 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

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

[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2015-07-27 20:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-24 21:33 Benjamin Cao
2015-02-24 23:49 ` Corinna Vinschen
2015-07-27 18:41   ` Benjamin Cao
2015-07-27 20:15     ` Corinna Vinschen [this message]
2015-07-28 17:26       ` Benjamin Cao
2015-07-29 11:49         ` Corinna Vinschen
2015-07-29 13:12           ` Benjamin Cao
2015-07-29 16:17             ` Corinna Vinschen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150727201519.GB12449@calimero.vinschen.de \
    --to=corinna-cygwin@cygwin.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).