X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 767A4384BC3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1596506466; bh=AcvtKgYrHTJvKOzaLr1rXLXKu5or2rlRo2MZ9l9F1CY=; h=References:In-Reply-To:Date:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=h94ECGG0abbNreOGAWF3xFdcrGmT61fkkL5vM2MCUnJm6KpSiyyHW/x/+rvCvYtAZ QXiuq9yvSVqtTLA7MqCea4kiSh2o/stB+w1JKT95DPKOuVMxO9XUg77x2Anl0/Lxg+ oIDVHcnEL7T/MSk85u+yZ+d9j2GXIg9L5kacV3qs= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 12210384C005 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=GuvE0m7UbwXKD3rKUWULn0DMJBCYEtjVMi+I0df38r0=; b=o8k5aEWI9ESOI/rqWiS36V/UmdH4oBNP2zbTeSlFOkInULYD8BGLJbu9ReeVZ2D1Bx jde9nhvb2AY7hIywZ3lKWwsx3u25ACKeFQ8NsXrTarE1Hs6QgUf0aLxfESj6dXhgFeUg 11VS284Cu+OCarhBjd/GV6AP52ME8LtFZMKTwisSN14xzTxkG9lLArGgREzcr3Sthsih V6WdqmxDoqa87mFjKcyMRmUwzRuY/V781cTjFE3mEhv+b2cNta7jppnbX0Jok7Fm8Sq/ 4ZpawKmQc1pWcLWJJTN53m8XCJFFyfg/JczudMLfoPf9JoJbe/esd9eYub/FDliTqAaX gaog== X-Gm-Message-State: AOAM530Rbjlchx+D6/VgZB6ZgOysc/LO8a14skDW7VbcWD5SBG2Yo9RQ Lube/e72PeyoJY+PaGEecH3ZCtgtpBtAMrPba9mLDk8= X-Google-Smtp-Source: ABdhPJzXBbz6QgycJwSP9/kaoZRg6ICVvk/aDWNmuaDXx8pvIsPrBuN6NDaZIJGQJa9EWWnTzNtEVWXNNhbDS1ZyIPo= X-Received: by 2002:a05:651c:1291:: with SMTP id 17mr5461344ljc.366.1596506461757; Mon, 03 Aug 2020 19:01:01 -0700 (PDT) MIME-Version: 1.0 References: <1869633229 DOT 76476 DOT 1595021996652 AT smtp4 DOT opayq DOT com> <0077be8f-2c24-68c3-c6ea-f6ece6b7b0cf AT cornell DOT edu> In-Reply-To: Date: Mon, 3 Aug 2020 21:57:23 -0400 Message-ID: Subject: Re: Cygwin PHP (all available versions) has a hard 4MB memory limit To: Ken Brown X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.29 List-Id: General Cygwin discussions and problem reports List-Archive: List-Post: List-Help: List-Subscribe: , From: Cary Lewis via Cygwin Reply-To: Cary Lewis Cc: km2z7kca0oge AT opayq DOT com, cygwin AT cygwin DOT com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Cygwin" I am running php on two different Windows 10 computers, and on one machine I can run composer with no issues, but on other I get our of memory issues. Both report: php -v PHP 7.3.7 (cli) (built: Jul 21 2019 18:10:35) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.3.7, Copyright (c) 1998-2018 Zend Technologies but trying to execute: composer require twilio/sdk on one of the machines results in this: PHP Fatal error: Out of memory (allocated 38273024) (tried to allocate 2098524 bytes) in phar:///usr/bin/composer/src/Composer/Util/RemoteFilesystem.php on line 459 Fatal error: Out of memory (allocated 38273024) (tried to allocate 2098524 bytes) in phar:///usr/bin/composer/src/Composer/Util/RemoteFilesystem.php on line 459 md5sum of /us/bin//php is the same on both computers. On Tue, Jul 21, 2020 at 4:45 PM Ken Brown via Cygwin wrote: > On 7/18/2020 10:11 PM, Ken Brown via Cygwin wrote: > > On 7/17/2020 5:39 PM, km2z7kca0oge--- via Cygwin wrote: > >> Hi there, > >> > >> Recently I've noticed that PHP seems have to hard 4MB memory limit, > > > > [...] > > > >> Example script: > >> ``` > >> >> > >> echo ini_get('memory_limit'), "\n"; > >> > >> file_get_contents(' > http://mirror.cwcs.co.uk/centos/8.2.2004/isos/x86_64/CentOS-8.2.2004-x86_64-dvd1.iso'); > > >> // A large file such as an ISO. > >> ``` > >> > >> Output: > >> $ php test.php > >> 128M > >> PHP Fatal error: Out of memory (allocated 4194304) (tried to allocate > 2097184 > >> bytes) in /c/Users/JackBlower/tmp-safe/test.php on line 5 > > > > Thanks for the simple reproduction steps. I've run this under gdb, and > the > > function zend_mm_alloc_huge, which tries to get a chunk of memory from > the > > system, seems to be failing when it tries to increase the zend heap from > 4MB to > > 6MB. I'm in the process of building an unoptimized version of php to > make > > debugging easier, in the hope of figuring out why the function is > failing. > > The problem is that some mmap calls are failing, for two reasons. The > first > (and less important) is a Cygwin bug, which is now fixed: > > > https://cygwin.com/git/?p=newlib-cygwin.git;a=commit;h=d8a8d2ce5953af3383aff019596bdf7f7aef6c41 > > The second is that mmap is sometimes called with MAP_FIXED, and these > calls may > fail. But these calls occur only because of the following hunk of the > patch > 7.1.9-malloc-cygwin.patch, which is used in the Cygwin build of php: > > --- origsrc/php-7.1.9/Zend/zend_alloc.c 2017-08-30 11:13:20.000000000 -0500 > +++ src/php-7.1.9/Zend/zend_alloc.c 2017-09-26 21:43:38.087650400 -0500 > @@ -719,7 +719,7 @@ static void *zend_mm_chunk_alloc_int(siz > /* chunk has to be aligned */ > zend_mm_munmap(ptr, size); > ptr = zend_mm_mmap(size + alignment - REAL_PAGE_SIZE); > -#ifdef _WIN32 > +#if defined(_WIN32) || defined(__CYGWIN__) > offset = ZEND_MM_ALIGNED_OFFSET(ptr, alignment); > zend_mm_munmap(ptr, size + alignment - REAL_PAGE_SIZE); > ptr = zend_mm_mmap_fixed((void*)((char*)ptr + (alignment - > offset)), size); > > I don't know the reason for this hunk of the patch. I suspect it was to > compensate for some deficiencies in Cygwin's mmap that have since been > fixed, > but only Yaakov (the php maintainer) can confirm this. > > After rebuilding php with that hunk of the patch removed, I get the > following > with your test case: > > $ php test.php > 128M > PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried > to > allocate 65011744 bytes) in /tmp/test.php on line 5 > > This seems to be what's expected, since 134217728 == 0x8000000 == 128M. > Here's > another example: > > $ php -d "memory_limit=256M" test.php > 256M > PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried > to > allocate 132120608 bytes) in /tmp/test.php on line 5 > > I'll follow up on the cygwin-apps list to see if we can get a rebuilt php > into > the distro. > > Ken > -- > 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 > -- 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