Edit report at https://bugs.php.net/bug.php?id=64935&edit=1
ID: 64935 Updated by: cataphr...@php.net Reported by: julien at palard dot fr Summary: Huge memory usage on unknown Content-Type Status: Open Type: Bug Package: Performance problem Operating System: GNU/Linux PHP Version: 5.4.15 Block user comment: N Private report: N New Comment: Handing such large requests is better done with enable_post_data_reading=0 Previous Comments: ------------------------------------------------------------------------ [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