PHP :: Bug #66283 :: Segmentation fault
| Bug #66283 | Segmentation fault | ||||
|---|---|---|---|---|---|
| Submitted: | 2013-12-13 08:41 UTC | Modified: | 2014-01-09 18:17 UTC | ||
| From: | jan dot kahoun at heureka dot cz | Assigned: | mysql (profile) | ||
| Status: | Closed | Package: | MySQLi related | ||
| PHP Version: | 5.4.22 | OS: | Centos 6.2 | ||
| Private report: | No | CVE-ID: | None | ||
[2013-12-13 08:41 UTC] jan dot kahoun at heureka dot cz
Description: ------------ Using mysqli and multi_query can sometimes lead to Segmentation fault when trying to free the result. Test script: --------------- http://codepad.org/WNxylU8G Expected result: ---------------- Just PHP Fatal error Actual result: -------------- PHP Fatal error: Allowed memory size of 96468992 bytes exhausted (tried to allocate 2 bytes) in /home/web/index.php on line 45 PHP Stack trace: PHP 1. {main}() /home/web/index.php:0 PHP 2. mysqli_result->free() /home/web/index.php:45 Fatal error: Allowed memory size of 96468992 bytes exhausted (tried to allocate 2 bytes) in /home/web/index.php on line 45 Call Stack: 0.0002 239480 1. {main}() /home/web/index.php:0 0.5828 96413160 2. mysqli_result->free() /home/web/index.php:45 Segmentation fault (core dumped)
Patches
bug66283_oom_during_cleanup_mitigation.diff (last revision 2014-01-09 18:13 UTC by johannes@php.net)Pull Requests
History
AllCommentsChangesGit/SVN commits
[2013-12-13 09:27 UTC] krakjoe@php.net
[2013-12-13 10:05 UTC] jan dot kahoun at heureka dot cz
-Status: Feedback +Status: Open
[2013-12-13 18:14 UTC] krakjoe@php.net
[2013-12-15 17:15 UTC] jan dot kahoun at heureka dot cz
-Status: Feedback +Status: Open
[2013-12-15 17:15 UTC] jan dot kahoun at heureka dot cz
Try this new version of the test code. Just create table in MySQL and insert the test data. Then run the test script, with filled your database setting (user, password and database name) e.g. from CLI. Database setup: CREATE TABLE IF NOT EXISTS `Test` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `parentId` smallint(5) unsigned NOT NULL, `seoId` varchar(255) COLLATE utf8_czech_ci NOT NULL, `name` varchar(255) COLLATE utf8_czech_ci NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; INSERT INTO `Test` (`id`, `parentId`, `seoId`, `name`) values('1','1','seoId','name'),('2','1','seoId','name'); PHP test script: <?php ini_set('memory_limit', '1M'); $mysqli = mysqli_init(); // set your database setting here by replacing default values 'user', 'password', 'dbname' $mysqli->real_connect('127.0.0.1', 'user', 'password', 'dbname', 'port'); $sql = str_repeat("SELECT * FROM Test LIMIT 100; SELECT * FROM Test LIMIT 100;", 300); $mysqli->multi_query($sql); $retArr = array(); do { if ($res = $mysqli->store_result()) { $ret = array(); while ($row = $res->fetch_assoc()) { $ret[] = $row; } $res->free(); $retArr[] = $ret; } } while ($mysqli->next_result()); ?> Actual result: PHP Fatal error: Allowed memory size of 1048576 bytes exhausted (tried to allocate 6 bytes) in /home/web/index.php on line 16 PHP Stack trace: PHP 1. {main}() /home/web/index.php:0 PHP 2. mysqli_result->free() /home/web/index.php:16 Fatal error: Allowed memory size of 1048576 bytes exhausted (tried to allocate 6 bytes) in /home/web/index.php on line 16 Call Stack: 0.0002 234568 1. {main}() /home/web/index.php:0 0.0273 1046488 2. mysqli_result->free() /home/web/index.php:16 Segmentation fault (core dumped) Expected result: Only PHP Fatal error without "Segmentation fault (core dumped)".[2013-12-18 08:18 UTC] jan dot kahoun at heureka dot cz
[2013-12-19 03:56 UTC] laruence@php.net
[2013-12-19 04:04 UTC] laruence@php.net
[2013-12-19 08:18 UTC] jan dot kahoun at heureka dot cz
[2013-12-22 11:22 UTC] felipe@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: mysql
[2014-01-09 18:17 UTC] johannes@php.net
[2014-01-17 09:21 UTC] jan dot kahoun at heureka dot cz