public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Peter Dons Tychsen <donpedro@tdcadsl.dk>
To: Ken Brown <kbrown@cornell.edu>, cygwin@cygwin.com
Subject: Re: mmap failure [was: cygrunsrv + sshd + rsync = 20 times too slow -- throttled?]
Date: Mon, 06 Sep 2021 22:52:19 +0200	[thread overview]
Message-ID: <03ffa4c3f3a1bf42e52f84af9a444bd0834de0ae.camel@tdcadsl.dk> (raw)
In-Reply-To: <3a63eb8c-3e8e-cd2c-b9de-8c34fa041a75@cornell.edu>

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

  reply	other threads:[~2021-09-06 20:52 UTC|newest]

Thread overview: 86+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-24 19:49 cygrunsrv + sshd + rsync = 20 times too slow -- throttled? Chris Roehrig
2021-08-24 23:43 ` Mark Geisert
2021-08-25  0:35   ` Chris Roehrig
2021-08-25  2:12     ` Chris Roehrig
2021-08-25  2:02 ` NightStrike
2021-08-25  3:20   ` Mark Geisert
2021-08-25 17:24     ` Chris Roehrig
2021-08-25 11:18 ` Takashi Yano
2021-08-25 17:31   ` Chris Roehrig
2021-08-25 17:52   ` Ken Brown
2021-08-25 18:18     ` Chris Roehrig
2021-08-25 18:51       ` Chris Roehrig
2021-08-26 15:44       ` Ken Brown
2021-08-25 20:33     ` Mario Emmenlauer
2021-08-26 15:47       ` Ken Brown
2021-08-25 21:29     ` Takashi Yano
2021-08-26 15:56       ` Ken Brown
2021-08-26 22:18         ` Ken Brown
2021-08-27 11:24           ` Takashi Yano
2021-08-27 16:00             ` Ken Brown
2021-08-27 17:21               ` Takashi Yano
2021-08-28  2:00                 ` Takashi Yano
2021-08-28  3:03                   ` Takashi Yano
2021-08-28  8:43                 ` Corinna Vinschen
2021-08-28  9:41                   ` Takashi Yano
2021-08-28 11:58                     ` Corinna Vinschen
2021-08-28 15:43                       ` Takashi Yano
2021-08-28 20:55                         ` Ken Brown
2021-08-29  8:41                           ` Takashi Yano
2021-08-29 22:42                             ` Ken Brown
2021-08-29 10:27                         ` Corinna Vinschen
2021-08-29  9:07                     ` Takashi Yano
2021-08-29 15:57                       ` Ken Brown
2021-08-29 19:24                         ` Chris Roehrig
2021-08-29 22:24                           ` Ken Brown
2021-08-30 23:58                             ` Chris Roehrig
2021-08-31 19:05                               ` Ken Brown
2021-08-31 19:53                                 ` Chris Roehrig
2021-08-31 20:23                                   ` Chris Roehrig
2021-08-31 21:29                                     ` Brian Inglis
2021-09-01 21:11                                     ` Chris Roehrig
2021-09-02 15:25                                       ` Ken Brown
2021-09-02 19:03                                         ` Chris Roehrig
2021-09-03 17:26                                           ` Ken Brown
2021-09-03 19:55                                           ` Corinna Vinschen
2021-09-03 20:59                                             ` Chris Roehrig
2021-09-04  8:32                                               ` Achim Gratz
2021-09-04 16:45                                               ` Brian Inglis
2021-09-05  8:18                                                 ` Achim Gratz
2021-09-05 15:11                                                   ` Brian Inglis
2021-09-06 10:42                                                     ` Achim Gratz
2021-09-04 22:37                                             ` mmap failure [was: cygrunsrv + sshd + rsync = 20 times too slow -- throttled?] Ken Brown
2021-09-04 22:54                                               ` Ken Brown
2021-09-04 22:58                                                 ` Ken Brown
2021-09-05  0:04                                                   ` Ken Brown
2021-09-05 13:24                                                     ` Ken Brown
2021-09-06 15:32                                                       ` Corinna Vinschen
2021-09-06 17:12                                                         ` Ken Brown
2021-09-06 17:38                                                           ` Ken Brown
2021-09-06 17:43                                                             ` Eliot Moss
2021-09-06 17:59                                                             ` Corinna Vinschen
2021-09-06 18:07                                                               ` Corinna Vinschen
2021-09-06 18:40                                                                 ` Ken Brown
2021-09-06 20:52                                                                   ` Peter Dons Tychsen [this message]
2021-09-06 20:54                                                                   ` Peter Dons Tychsen
2021-09-06 21:24                                                                     ` Ken Brown
2021-09-06 21:31                                                                       ` Ken Brown
2021-09-07  3:34                                                                       ` Brian Inglis
2021-09-07 16:28                                                                         ` Ken Brown
2021-09-07 21:52                                                                           ` Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2021-09-07 22:44                                                                             ` Ken Brown
2021-09-08  6:14                                                                               ` Sam Edge
2021-09-08  8:18                                                                         ` Corinna Vinschen
2021-09-07 21:41                                                                       ` Peter Dons Tychsen
2021-09-04 23:18                                               ` Brian Inglis
2021-08-29 19:37                         ` cygrunsrv + sshd + rsync = 20 times too slow -- throttled? Takashi Yano
2021-08-29 21:09                           ` Ken Brown
2021-08-29 21:04                       ` Ken Brown
2021-08-30  0:13                         ` Takashi Yano
2021-08-30  0:22                           ` Takashi Yano
2021-08-30  2:15                             ` Ken Brown
2021-08-30  8:02                               ` Takashi Yano
2021-08-28 15:17                   ` Ken Brown
2021-09-16 22:00 ` Keith Christian
2021-09-16 22:48   ` Ken Brown
2021-09-16 22:58     ` Keith Christian

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=03ffa4c3f3a1bf42e52f84af9a444bd0834de0ae.camel@tdcadsl.dk \
    --to=donpedro@tdcadsl.dk \
    --cc=cygwin@cygwin.com \
    --cc=kbrown@cornell.edu \
    /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).