From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-eopbgr760114.outbound.protection.outlook.com [40.107.76.114]) by sourceware.org (Postfix) with ESMTPS id D93993857C45 for ; Tue, 21 Jul 2020 20:45:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D93993857C45 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W08SXDuyRFmTNKWP7Z4F+v3Yx+4Igjfbhw9c5w7a9grsE0uWXya5K1jTZJ7FKP3ttqZL6C5Yj6BjxwyfF4q6rN9dj0eeydh6E2pKOzpiQUbpCnDyuRjCpsK4f1lo+xUQzRjQlF39sYDTLUo4nl6uVkihP4SNfLr6L8yv9M9vBLXe3ee/cXYcz05V7+E8rNx0PGh0kd59tlcNszJFLgLI0iSvhoQxdC6h04JRtkHUDljB2jHSnJxwv+5kxnY5vE5OgZ1SUXjzDuHa3zXNZ22aakKqY2CS8XqvRfKZQznkkaRjO1sqD8p8QKI3Y2tHrrLU/Ce1IQ76vAeLcQX4qXHQvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Cx4ZxXob8g34ywfCemaJpItfxTc7L+riFWwiJ4+qbVA=; b=FjgN/MzO/mocJo2wwN7JnTd5NebL+Mgx6q7A02X4xKvFHgE9FOYELIfM4A4zC/d7J8dpabNwQ2Za5jigi6Av49KNZQKCFAL3mWxC0cxj5WaKvj22YprRvQ+yJfcqKpcJLkVe/NBEkQp9ENOCx1zvO5gRVlb6rkI8/JPTHPgOxYMbVWv4DmB5lPEmJpI0St2D4OOoYP8rkGXHCLvwr5igI5r6Li3aeEpank2VQ+x1ljijBl99zH/hssx8gHGyNwnblFa6igY8hBYCGsTdckyoDtzCycC1w8dRxPTpfbe+huXJto8Glbp0UX/Tpc/zcvc6MWUgByfsjHCzECibntTFqA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=cornell.edu; dmarc=pass action=none header.from=cornell.edu; dkim=pass header.d=cornell.edu; arc=none Received: from MN2PR04MB6176.namprd04.prod.outlook.com (2603:10b6:208:e3::13) by MN2PR04MB5885.namprd04.prod.outlook.com (2603:10b6:208:a5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3195.23; Tue, 21 Jul 2020 20:45:07 +0000 Received: from MN2PR04MB6176.namprd04.prod.outlook.com ([fe80::184d:a265:1d48:499a]) by MN2PR04MB6176.namprd04.prod.outlook.com ([fe80::184d:a265:1d48:499a%7]) with mapi id 15.20.3195.025; Tue, 21 Jul 2020 20:45:06 +0000 Subject: Re: Cygwin PHP (all available versions) has a hard 4MB memory limit To: km2z7kca0oge@opayq.com, cygwin@cygwin.com References: <1869633229.76476.1595021996652@smtp4.opayq.com> <0077be8f-2c24-68c3-c6ea-f6ece6b7b0cf@cornell.edu> From: Ken Brown Message-ID: Date: Tue, 21 Jul 2020 16:45:04 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 In-Reply-To: <0077be8f-2c24-68c3-c6ea-f6ece6b7b0cf@cornell.edu> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-ClientProxiedBy: MN2PR01CA0060.prod.exchangelabs.com (2603:10b6:208:23f::29) To MN2PR04MB6176.namprd04.prod.outlook.com (2603:10b6:208:e3::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [IPv6:2604:6000:b407:7f00:ad12:1782:80ed:dfca] (2604:6000:b407:7f00:ad12:1782:80ed:dfca) by MN2PR01CA0060.prod.exchangelabs.com (2603:10b6:208:23f::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3195.18 via Frontend Transport; Tue, 21 Jul 2020 20:45:06 +0000 X-Originating-IP: [2604:6000:b407:7f00:ad12:1782:80ed:dfca] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1cbac983-7410-4daf-e1a2-08d82db6f381 X-MS-TrafficTypeDiagnostic: MN2PR04MB5885: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: q/kpmHDaXhNbjPLnAaxciHW2rFAL7JNKNPIUBoKVmUDIVZQwYAy82NEtEpcM47mpRdtaZ7Bdlm82skO0TN25uZJu0/n3xaASENt2cuLJZ8wnMu+LP7WQAV1pGPKdVucJFgTDcwhA0bE4SpTEwz7fx3O5VuH3nb8vzmFwLi+B1/2/Qx99LlRWzxejGdWO50ijHPY58IvM6rR0G5K4Cuil3qN97nqL/ZswU6mGS/ODHBaSg7RQeuYTDsQvl2wtVBZS49BeJZrMtY9y3zyr73JVPXHZeTqc6swfdSAkUV1E7KOuJ5ZzeT6J8gssesV+FjKA/ohfi+C9dETv8fTFUhpg8z1k8jA6yyS4R8sAfK3t7bJ6z95+3G5XE57DRxmCbUA8mUOHKaAf2BoHfjX04GBDQCrw51ocqcwY3OPROycScB4ek5RDUBR5VukWC6NEzxaAefpBm69u7vHVgdpyhvRP1Q== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MN2PR04MB6176.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(396003)(346002)(376002)(39860400002)(366004)(136003)(8936002)(8676002)(478600001)(83380400001)(31686004)(966005)(36756003)(16526019)(5660300002)(186003)(31696002)(2906002)(66476007)(53546011)(52116002)(316002)(786003)(86362001)(2616005)(66556008)(66946007)(6486002)(16799955002)(75432002)(43740500002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: h5ndOLs9tju+sJBl2TTqwg71CfciZucpI95m1WOAPTJ34qnRQ9JPnKBrTdL0qiPuRjOYh0VR58IUq+C6SiRAvaR90onSjU9o87wuJboUK7u/TQli8qDnlWj4G2LrdeKc5vOigQ0ytayxEEe5A8w85zc5KPmbtMFxF88i+8ZkGdyUNA3PrJQABJDx7R+qFYRZGcwID7CWzweoep93/G2NQfYtifK+dLx9lwQUX3PsYfFRmxcrvUAy4AJicn/Gcg+djFpRmYXV2EtgUU4Gq88no+mAYfpkp6UzPokIiKHbqn8k53zesfzaBPYwmxiqNKIWgdcvPVkvnNpNs5vjGFs93PPW9B5g2Fq4DvmzvOJK5V196U0BMbO4B9OZ14oI+6xt7PwwzEVw5/FBQGDpA4+HBZg0dVQmAgr9sHuNMcljh6Rt6zhgEN9lNUJJJeA2hmvGegpsSOgarnjYgNDN7TSwbwk5ZQ8xaA6FgObSpT0zYDaAm2j1Z++9FrmU76kUJD1xE4LgrUaJNj67G809pBrOgO6doAxeb0TCnMo7O0RcRwU= X-OriginatorOrg: cornell.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 1cbac983-7410-4daf-e1a2-08d82db6f381 X-MS-Exchange-CrossTenant-AuthSource: MN2PR04MB6176.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2020 20:45:06.8296 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 5d7e4366-1b9b-45cf-8e79-b14b27df46e1 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2dVCG7nMEL2hG5ykErqiiZ6uSxKgUlEbgUpBIw22MdxpCWYVM8gaPQoC0tp/mhqt0FVVxaUcXv+y1vZp3Up/rg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR04MB5885 X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_00, DKIM_INVALID, DKIM_SIGNED, KAM_DMARC_STATUS, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: cygwin@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Jul 2020 20:45:10 -0000 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