Bug #64935 [Opn->Csd]: Huge memory usage on unknown Content-Type

From: Date: Wed, 19 Nov 2014 12:29:35 +0000
Subject: Bug #64935 [Opn->Csd]: Huge memory usage on unknown Content-Type
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-188678@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=64935&edit=1 ID: 64935 Updated by: mike@php.net Reported by: julien at palard dot fr Summary: Huge memory usage on unknown Content-Type -Status: Open +Status: Closed Type: Bug Package: Performance problem Operating System: GNU/Linux PHP Version: 5.4.15 -Assigned To: +Assigned To: mike Block user comment: N Private report: N New Comment: PHP-5.6 uses a temp PHP stream to store the data. Previous Comments: ------------------------------------------------------------------------ [2013-05-29 07:54:14] cataphract@php.net Handing such large requests is better done with enable_post_data_reading=0 ------------------------------------------------------------------------ [2013-05-28 10:07:29] julien at palard dot fr Description: ------------ When a POST have an unknwon Content-Type, the php_default_post_reader store the body of the request three times : * In SG(request_info).post_data * In SET_VAR_STRINGL("HTTP_RAW_POST_DATA", ... * In SG(request_info).raw_post_data So, getting a 500Mb request body result in a 1.5Gb memory usage, easily triggering a "memory limit exhausted" error. Known content types are found in main/php_content_types.c and are "application/x-www-form-urlencoded" and "multipart/form-data", so this case is easily triggered. This fact seems well known as we can read in main/php_content_types.c:59 : /* for php://input stream: some post handlers modify the content of request_info.post_data so for now we need a copy for the php://input stream in the long run post handlers should be changed to not touch request_info.post_data for memory preservation reasons */ Solving this comment only fix 1/2 of the bug, keeping the body stored in two different locations, but it's a first step. I only open this ticket to track the history of this issue, I do not really need it to be fixed. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=64935&edit=1

« previous php.bugs (#188678) next »