delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/01/11/05:34:59

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <07f601c19a8b$56af1150$0200a8c0@lifelesswks>
From: "Robert Collins" <robert DOT collins AT itdomain DOT com DOT au>
To: "Corinna Vinschen" <cygwin AT cygwin DOT com>
References: <200201101259 DOT g0ACxFN12728 AT dymwsm10 DOT mailwatch DOT com> <20020110144551 DOT J12057 AT cygbert DOT vinschen DOT de> <033d01c199de$4578ab10$0200a8c0 AT lifelesswks> <20020110150729 DOT L12057 AT cygbert DOT vinschen DOT de>
Subject: Re: ksh on cygwin
Date: Fri, 11 Jan 2002 21:32:57 +1100
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
X-OriginalArrivalTime: 11 Jan 2002 10:32:56.0212 (UTC) FILETIME=[551C1540:01C19A8B]

----- Original Message -----
From: "Corinna Vinschen" <cygwin AT cygwin DOT com>

> mmap (MapViewOfFile resp.) alwaus map whole pages.  A page is 4096
> bytes long.
>
> If a file is, say, 8190 bytes, then we have a two page map, size 8192.
> So we have two trailing 0 bytes.  If getpagesize() returns 4096, gcc
can
> count that correctly, if getpagesize returns 65536, gcc assumes 57346
> trailing bytes.  No problem, gcc only accesses exactly one trailing 0
byte.
>
> If the file is 8192 bytes long, mmap maps exactly 8192 bytes, no
> trailing bytes left.  If getpagesize() returns 4096, gcc knows that,
> if getpagesize returns 65536, gcc assumes 57344 trailing bytes.
> Now it is a problem, since the one trailing 0 byte doesn't exist.
> Segmentation fault.

Ok. Lets see if I understand:

Let m be the size reported by getpagesize.
Let f be the size of a file gcc is mmaping.

1) Gcc can't handle a remainder of m divided by f that is greater than
<some number between  2 and 57346>.

2) If the remainfer of m divided by f is 0, gcc behaves correctly.

3) If f > m, then gcc assumes that f is m bytes long?

Sounds to me like gcc is badly broken.
i.e. in your prior example:
where m = 4096
if the file is 2048 bytes long, mmap maps exactly 2048 bytes. if m is
4096, gcc assumes there is  2048 trailing bytes. Now it is a problem,
since the one trailing 0 byte doesn't exist. Segmentation fault.

IOW, I don't see how the 4K vs 64K thing affects this scenario, it seems
to be driven purely by the fact the m != 1.

Rob


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


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