delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2021/09/06/16:53:45

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3D5D5385C419
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1630961623;
bh=frkwgsCDGUdeKTjkumjugF5QlPDetvs9IrzF5pEAOWM=;
h=Subject:To:Date:In-Reply-To:References:List-Id:List-Unsubscribe:
List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:
From;
b=Wt4duxggqINrIMy0hhJzaBm5k9NQOTm2/M0k9yQNxyZxhxI1hpVEota1is2uGL7uF
Mnsrucc7pyjAoJT4JpY+RdBcsOeqLZCqEBmukZnGH3CtyQ7uY7ojNcZ+/WuxlXZGgb
PzE0zXEOkTezf/jp5Prilz3/S7l8gZK1DuUfyNqc=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B79C53857C60
X-mail-filterd: {"version":"1.2.1", "queueID":"4H3LFD4L7Yz5by",
"contextId":"97eb1de0-0970-424f-b41d-377446712050"}
X-mail-filterd: {"version":"1.2.1", "queueID":"4H3LF043mrz1Wk",
"contextId":"06272dd4-64eb-4ffe-8088-606350b3425a"}
X-yse-mailing: LEGIT
X-yse-spamrating: 36
X-yse-spam: not-spam
X-yse-spamcause: OK,
(-100)(0000)gggruggvucftvghtrhhoucdtuddrgedvtddrudeffedgudehgecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfvffevpdggtfgfpffufgeuufevtffkuefgpdfqfgfvnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefkuffhvfffjghftggfggfgsehtkeertddtreejnecuhfhrohhmpefrvghtvghrucffohhnshcuvfihtghhshgvnhcuoeguohhnphgvughrohesthgutggrughslhdrughkqeenucggtffrrghtthgvrhhnpefgleduheevveetueefledvveefjeeitefffeevhedvheefheehhefgffejueeuieenucffohhmrghinheptghpphhrvghfvghrvghntggvrdgtohhmnecukfhppeelgedrudegjedriedtrdeggeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhephhgvlhhopegluddtrddtrddtrdektdgnpdhinhgvthepleegrddugeejrdeitddrgeegpdhmrghilhhfrhhomhepughonhhpvggurhhosehtuggtrggushhlrdgukhdprhgtphhtthhopehksghrohifnhestghorhhnvghllhdrvgguuhdprhgtphhtthhopegthihgfihinhestgihghifihhnrdgtohhm
Message-ID: <03ffa4c3f3a1bf42e52f84af9a444bd0834de0ae.camel@tdcadsl.dk>
Subject: Re: mmap failure [was: cygrunsrv + sshd + rsync = 20 times too slow
-- throttled?]
To: Ken Brown <kbrown AT cornell DOT edu>, cygwin AT cygwin DOT com
Date: Mon, 06 Sep 2021 22:52:19 +0200
In-Reply-To: <3a63eb8c-3e8e-cd2c-b9de-8c34fa041a75@cornell.edu>
References: <YTJ9wwbHqeoGxZMP AT calimero DOT vinschen DOT de>
<c54c8815-44fe-a837-211e-6497a185c2e8 AT cornell DOT edu>
<88fde5d5-4897-8792-576a-a62be0092ad8 AT cornell DOT edu>
<94b5b6cf-1670-cbdd-2f51-84dae09d27b6 AT cornell DOT edu>
<387d9062-1ff9-6eab-e268-e5070352a193 AT cornell DOT edu>
<40275f71-7c10-55a9-e6c8-a948e32c37ac AT cornell DOT edu>
<YTY0oN9x7wNtJAKx AT calimero DOT vinschen DOT de>
<d3c9bb17-b859-e7b1-d7e6-c421d0f37836 AT cornell DOT edu>
<33ae27cb-4e45-7484-40d1-6cbd88c958f1 AT cornell DOT edu>
<YTZXGlvWWUk23bJI AT calimero DOT vinschen DOT de>
<YTZY/vytb7nagC6M AT calimero DOT vinschen DOT de>
<3a63eb8c-3e8e-cd2c-b9de-8c34fa041a75 AT cornell DOT edu>
User-Agent: Evolution 3.38.4 (3.38.4-1.fc33)
MIME-Version: 1.0
X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00, DKIM_SIGNED,
DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, SPF_HELO_NONE, SPF_PASS,
TXREP autolearn=ham autolearn_force=no version=3.4.4
X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: Peter Dons Tychsen via Cygwin <cygwin AT cygwin DOT com>
Reply-To: Peter Dons Tychsen <donpedro AT tdcadsl DOT dk>
Errors-To: cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com>
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 186Krii8014690

Hi there,

On Mon, 2021-09-06 at 14:40 -0400, Ken Brown via Cygwin wrote:
> > No, wait.  I get what you say.  The optimzation settings of the test
> > case should have no influence on the code inside the DLL.  That
> > doesn't
> > make sense for sure.  However, I ran the testcase under GDB, I could
> > reproduce the issue, and I could fix it by setting mmap_ext.Reserved
> > = 0;
> > Go figure!
> 
> I don't get it, but I can confirm that the problem is fixed.

That sounds a bit like a voodoo fix, that could quickly regress again.

Here is my 2 cents:

Currently the mmap_ext structure is setup like this:

 215       MEM_EXTENDED_PARAMETER mmap_ext = {
 216         .Type = MemExtendedParameterAddressRequirements,
 217         .Pointer = (PVOID) &mmap_req
 218       };

This means that all other entries in the struct are zero at
initialization as described here:
https://en.cppreference.com/w/c/language/struct_initialization

So if you set "mmap_ext.Reserved = 0" again after that its a double
failure. 

1) The compiler should ignore it as it is redundent.
2) It makes no sense, as it is already zero :-)

Since it is not ignored, the compiler clearly puts in code to to
reinitialize the variable (which some compilers do not optimize for).

The reason this makes it "work" it probably because of some other stack
curruption that is going on which then disappears because of the code
moving around a bit due to the new line. My best guess would be that
other fun stuff in the same location would also "fix" the problem.

These are not the droids you are looking for. The real problem is
elsewhere, and is likely due to some stack-smashing going on. This is
also likely why recompiling the test program makes a difference as that
changes what goes on the variable stack. When the code moves around
again (e.g. new compiler version), it could break again.

Looking at the test program -02 vs -O0:

pushq	%rbp
.seh_pushreg	%rbp
movq	%rsp, %rbp
.seh_setframe	%rbp, 0
subq	$64, %rsp
.seh_stackalloc	64
.seh_endprologue

vs

subq	$56, %rsp
.seh_stackalloc	56

Which gives a different stack layout. I think the problem must be in
the start of mmap() or subsequent calls like CreateMapping() and
MapView(). Something smashes or affects the stack.

Thanks,

/pedro

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


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