delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2017/05/02/06:29:13

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:from:subject:to:message-id:date:mime-version
:content-type:content-transfer-encoding; q=dns; s=default; b=OjV
lsrW0xB4t2Mi/U4krB02CkHNUNi3hf7khKFUBYc11IlqpgOmFtR8J0JSzxwwDApN
P8NJUlioCq5kqIUWAXL91FThahIAXoduRZtzDsQNC6+OsxfR4IqeZmSjteR8QR9L
zJUH19U4j63hmxQdT3+GsUZaiRAV0bAGAm2BhOio=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:from:subject:to:message-id:date:mime-version
:content-type:content-transfer-encoding; s=default; bh=RX6S3yWfh
GmNmKwysRVOKdvPUso=; b=XP3bgCsEvxKrWKeTKC1T38NkV+wWkoQFk4gSobfnO
GovvgW0Z6iZI0rTNmzZbQzG2UaOfuPY5uRBFY53Djtjg/F8zhOCa3FA/AMksTSnL
8gofsIOozezVcxPIiYaHg6deA6hCZM3e++vmQ2UgDz4pBtXuBI13MMfj/9SJRZO2
Lc=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=php, boundaries, reality, UD:php
X-HELO: mail-wm0-f51.google.com
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=EkJuz6EBePxYwCTzxCtgvyZ+tnRSKmQ0so0iBjLLsko=; b=E+owT4gfJtm4j/DAjWP+DwhzDxey/TDNTPkX8e06NC+judWENmW7KRlbAXXixQyO94 xdDJO0x2wfTyeFxa3hDx65S9/wIvf8n7ptVoQTNOcS+SqNna8jRGtHqVIQc0TIKjarcw J00DR8RCmUG20bxOKsL3jSxcg/nIneyZo7xywUW/vxu0zDWV7SKBX0NEENnoxfyd1A56 xfL+o1ueCRNyvzz/ZNOC8j5iDHq6E5Rx+FkZDx7ULdeChlekyheZlNbOiQUy5+OxyIAg 5agzdF0ISaXLiYGTg4pvBANaMtXlM5ZVA8szURQO/XrYEFjtcjB+CcrmMiO9y3AdX012 CQug==
X-Gm-Message-State: AN3rC/7BBUXgeFh05pkgJY/PSeSCT9Z/wyicDfmODHgq3riIkiuNHJ2x Cw0qT67aDfCbxd9r2d0=
X-Received: by 10.28.67.68 with SMTP id q65mr1733309wma.142.1493720933567; Tue, 02 May 2017 03:28:53 -0700 (PDT)
From: Richard H Lee <ricardohenrylee AT gmail DOT com>
Subject: Fix for REAL_PAGE_SIZE in PHP
To: cygwin AT cygwin DOT com
Message-ID: <528aeb1a-9a9d-0afd-7372-576e8c94ae81@gmail.com>
Date: Tue, 2 May 2017 11:28:49 +0100
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
X-IsSubscribed: yes

There is a bug with PHP on Cygwin where it segfaults if the php file
size is a multiple of 4K.

https://bugs.php.net/bug.php?id=65312

PHP mmap()s source files as it it faster than using normal I/O.

The problem is with the page size in Cygwin. When a file is mmap()ed
to memory, any remaining bytes after the EOF in the last page are
zero'ed out. So when PHP reads the bytes after the EOF, it expects to
find zeroes.

In most systems the page size is 4K. In Windows the page size is also
4K, but aligned to a boundary of 64K (allocation granularity). Cygwin
reconciles this by making the page size 64K. So in reality, Cygwin
pages are 64K big, backed by 4K pages allocated along 64K boundaries.

When PHP reads a file, it looks at the file size. If there are enough
bytes to read ahead in the last memory page after the EOF, PHP will use
mmap. Else it will open the file normally.

When PHP is given a 4K file on Cygwin, it sees that the file and the
bytes for reading ahead will easily fit into a 64K page (in
Cygwin). So it mmap()s the file. However only one 4K page (in Windows)
is mapped to. The remaining 60K pages are not. When PHP reads ahead
past the EOF, it reads into page which has not been mapped to. This
results in a segfault.

Changing the REAL_PAGE_SIZE to 4096 fixes the issue.

Should this fix go upstream to PHP or be submitted to the PHP package
within Cygwin?


Richard

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

- Raw text -


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