From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 42432 invoked by alias); 2 May 2017 10:28:55 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 42406 invoked by uid 89); 2 May 2017 10:28:55 -0000 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 Received: from mail-wm0-f51.google.com (HELO mail-wm0-f51.google.com) (74.125.82.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 02 May 2017 10:28:53 +0000 Received: by mail-wm0-f51.google.com with SMTP id u65so107417981wmu.1 for ; Tue, 02 May 2017 03:28:55 -0700 (PDT) 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) Received: from [192.168.1.6] (79-67-178-202.dynamic.dsl.as9105.com. [79.67.178.202]) by smtp.gmail.com with ESMTPSA id x20sm672451wme.0.2017.05.02.03.28.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 May 2017 03:28:52 -0700 (PDT) From: Richard H Lee Subject: Fix for REAL_PAGE_SIZE in PHP To: cygwin@cygwin.com Message-ID: <528aeb1a-9a9d-0afd-7372-576e8c94ae81@gmail.com> Date: Tue, 02 May 2017 10:28:00 -0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2017-05/txt/msg00010.txt.bz2 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