Bug #73370 [Com]: falsely exits with "Out of Memory" when using USE_ZEND_ALLOC=0
| From: | jim dot hofer at gmail dot com | Date: | Tue, 25 Oct 2016 16:02:58 +0000 |
| Subject: | Bug #73370 [Com]: falsely exits with "Out of Memory" when using USE_ZEND_ALLOC=0 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-205003@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=73370&edit=1
ID: 73370
Comment by: jim dot hofer at gmail dot com
Reported by: jim dot hofer at gmail dot com
Summary: falsely exits with "Out of Memory" when using
USE_ZEND_ALLOC=0
Status: Feedback
Type: Bug
Package: MySQLi related
Operating System: Irrelevant
PHP Version: Irrelevant
Assigned To: laruence
Block user comment: N
Private report: N
New Comment:
I've tried to apply the patch but it's being rejected.
I'm using php-7.0.12-2.remi.src.rpm to apply the patch and build the rpm
Previous Comments:
------------------------------------------------------------------------
[2016-10-22 07:07:52] laruence@php.net
please try follow patch:
diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c
index 40eb100..5c9f124 100644
--- a/Zend/zend_alloc.c
+++ b/Zend/zend_alloc.c
@@ -2850,7 +2850,9 @@ static ZEND_COLD ZEND_NORETURN void zend_out_of_memory(void)
ZEND_API void * __zend_malloc(size_t len)
{
- void *tmp = malloc(len);
+ void *tmp;
+ len = MAX(len, 1);
+ tmp = malloc(len);
if (EXPECTED(tmp)) {
return tmp;
}
thanks
------------------------------------------------------------------------
[2016-10-21 18:29:59] jim dot hofer at gmail dot com
Description:
------------
I'm using USE_ZEND_ALLOC=0 for some cli scripts due this bug https://bugs.php.net/bug.php?id=72736
When using USE_ZEND_ALLOC=0 and querying mysql with buffered queries on and the select query returns
an empty result set the script exits with the message "Out of Memory"
Setting the query to use unbuffered results in expected behavior.
Also, not setting USE_ZEND_ALLOC=0 and querying unbuffered returns results in expected behavior
This bug does not affect 7.0.11
Test script:
---------------
<?php
$mysqli = new mysqli("localhost", "root");
$result = $mysqli->query("SELECT * FROM mysql.user WHERE User = 'test'",
MYSQLI_USE_RESULT)->fetch_all();
var_dump($result);
$result = $mysqli->query("SELECT * FROM mysql.user WHERE User =
'test'")->fetch_all();
var_dump($result);
Expected result:
----------------
array(0) {
}
array(0) {
}
Actual result:
--------------
array(0) {
}
Out of memory
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=73370&edit=1