php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68974 Memory leaks
Submitted: 2015-02-02 16:46 UTC Modified: 2016-04-05 12:03 UTC
From: yunosh@php.net Assigned: laruence (profile)
Status: Closed Package: PCRE related
PHP Version: master-Git-2015-02-02 (Git) OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
23 + 39 = ?
Subscribe to this entry?

 
 [2015-02-02 16:46 UTC] yunosh@php.net
Description:
------------
Running our Routes testing suite (https://github.com/horde/horde/tree/master/framework/Routes) I get a bunch of memory leaks.

$ php framework/Routes/test/Horde/Routes/AllTests.php 
PHPUnit 4.4.0 by Sebastian Bergmann.

...............................................................  63 / 127 ( 49%)
.........................................S..................... 126 / 127 ( 99%)
.

Time: 679 ms, Memory: 10.00Mb

OK, but incomplete, skipped, or risky tests!
Tests: 127, Assertions: 868, Skipped: 1.
[Mon Feb  2 16:40:55 2015]  Script:  '/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php'
/home/vagrant/php-src/Zend/zend_variables.c(247) :  Freeing 0x7FE0B8E56000 (64 bytes), script=/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php
Last leak repeated 9 times
[Mon Feb  2 16:40:55 2015]  Script:  '/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php'
/home/vagrant/php-src/Zend/zend_API.c(896) :  Freeing 0x7FE0B8E56360 (64 bytes), script=/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php
Last leak repeated 1 time
[Mon Feb  2 16:40:55 2015]  Script:  '/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php'
/home/vagrant/php-src/Zend/zend_string.h(97) :  Freeing 0x7FE0B8E58A00 (32 bytes), script=/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php
Last leak repeated 205 times
[Mon Feb  2 16:40:55 2015]  Script:  '/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php'
/home/vagrant/php-src/Zend/zend_string.h(165) :  Freeing 0x7FE0B8EBEA00 (32 bytes), script=/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php
Last leak repeated 3 times
[Mon Feb  2 16:40:55 2015]  Script:  '/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php'
/home/vagrant/php-src/Zend/zend_string.h(97) :  Freeing 0x7FE0B8F12880 (32 bytes), script=/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php
Last leak repeated 1 time
[Mon Feb  2 16:40:55 2015]  Script:  '/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php'
/home/vagrant/php-src/Zend/zend_string.h(97) :  Freeing 0x7FE0B8F3B600 (32 bytes), script=/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php
Last leak repeated 1 time
[Mon Feb  2 16:40:55 2015]  Script:  '/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php'
/home/vagrant/php-src/Zend/zend_string.h(97) :  Freeing 0x7FE0B7A6B8C0 (32 bytes), script=/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php
Last leak repeated 6 times
[Mon Feb  2 16:40:55 2015]  Script:  '/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php'
/home/vagrant/php-src/Zend/zend_string.h(165) :  Freeing 0x7FE0B7A6D180 (32 bytes), script=/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php
Last leak repeated 10 times
[Mon Feb  2 16:40:55 2015]  Script:  '/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php'
/home/vagrant/php-src/Zend/zend_string.h(97) :  Freeing 0x7FE0B7A7C370 (48 bytes), script=/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php
Last leak repeated 4 times
[Mon Feb  2 16:40:55 2015]  Script:  '/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php'
/home/vagrant/php-src/Zend/zend_execute.c(501) :  Freeing 0x7FE0B7B44818 (24 bytes), script=/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php
Last leak repeated 20 times
[Mon Feb  2 16:40:55 2015]  Script:  '/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php'
/home/vagrant/php-src/Zend/zend_hash.c(154) :  Freeing 0x7FE0B7B4A9C0 (256 bytes), script=/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php
/home/vagrant/php-src/Zend/zend_alloc.c(2247) : Actual location (location was relayed)
[Mon Feb  2 16:40:55 2015]  Script:  '/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php'
/home/vagrant/php-src/Zend/zend_hash.c(271) :  Freeing 0x7FE0B7B4AD80 (288 bytes), script=/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php
/home/vagrant/php-src/Zend/zend_alloc.c(2247) : Actual location (location was relayed)
Last leak repeated 1 time
[Mon Feb  2 16:40:55 2015]  Script:  '/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php'
/home/vagrant/php-src/Zend/zend_hash.c(1249) :  Freeing 0x7FE0B7B4AEC0 (256 bytes), script=/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php
/home/vagrant/php-src/Zend/zend_alloc.c(2247) : Actual location (location was relayed)
[Mon Feb  2 16:40:55 2015]  Script:  '/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php'
/home/vagrant/php-src/Zend/zend_variables.c(247) :  Freeing 0x7FE0B7B9C360 (64 bytes), script=/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php
Last leak repeated 19 times
[Mon Feb  2 16:40:55 2015]  Script:  '/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php'
/home/vagrant/php-src/Zend/zend_API.c(896) :  Freeing 0x7FE0B7B9D480 (64 bytes), script=/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php
Last leak repeated 3 times
[Mon Feb  2 16:40:55 2015]  Script:  '/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php'
/home/vagrant/php-src/Zend/zend_hash.c(422) :  Freeing 0x7FE0B7B9E000 (256 bytes), script=/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php
/home/vagrant/php-src/Zend/zend_alloc.c(2247) : Actual location (location was relayed)
[Mon Feb  2 16:40:55 2015]  Script:  '/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php'
/home/vagrant/php-src/Zend/zend_string.h(97) :  Freeing 0x7FE0B7BBDE80 (32 bytes), script=/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php
Last leak repeated 1 time
[Mon Feb  2 16:40:55 2015]  Script:  '/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php'
/home/vagrant/php-src/Zend/zend_hash.c(1249) :  Freeing 0x7FE0B780A280 (256 bytes), script=/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php
/home/vagrant/php-src/Zend/zend_alloc.c(2247) : Actual location (location was relayed)
Last leak repeated 370 times
[Mon Feb  2 16:40:55 2015]  Script:  '/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php'
/home/vagrant/php-src/Zend/zend_hash.c(271) :  Freeing 0x7FE0B780B7C0 (288 bytes), script=/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php
/home/vagrant/php-src/Zend/zend_alloc.c(2247) : Actual location (location was relayed)
Last leak repeated 139 times
[Mon Feb  2 16:40:55 2015]  Script:  '/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php'
/home/vagrant/php-src/Zend/zend_hash.c(422) :  Freeing 0x7FE0B780BA40 (256 bytes), script=/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php
/home/vagrant/php-src/Zend/zend_alloc.c(2247) : Actual location (location was relayed)
Last leak repeated 215 times
[Mon Feb  2 16:40:55 2015]  Script:  '/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php'
/home/vagrant/php-src/Zend/zend_hash.c(154) :  Freeing 0x7FE0B780C1C0 (256 bytes), script=/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php
/home/vagrant/php-src/Zend/zend_alloc.c(2247) : Actual location (location was relayed)
Last leak repeated 109 times
[Mon Feb  2 16:40:55 2015]  Script:  '/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php'
/home/vagrant/php-src/Zend/zend_variables.c(247) :  Freeing 0x7FE0B7815000 (64 bytes), script=/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php
Last leak repeated 670 times
[Mon Feb  2 16:40:55 2015]  Script:  '/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php'
/home/vagrant/php-src/Zend/zend_API.c(896) :  Freeing 0x7FE0B78154E0 (64 bytes), script=/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php
Last leak repeated 102 times
[Mon Feb  2 16:40:55 2015]  Script:  '/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php'
/home/vagrant/php-src/Zend/zend_string.h(165) :  Freeing 0x7FE0B782F780 (40 bytes), script=/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php
Last leak repeated 21 times
[Mon Feb  2 16:40:55 2015]  Script:  '/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php'
/home/vagrant/php-src/Zend/zend_vm_execute.h(28517) :  Freeing 0x7FE0B7830300 (64 bytes), script=/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php
Last leak repeated 36 times
[Mon Feb  2 16:40:55 2015]  Script:  '/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php'
/home/vagrant/php-src/Zend/zend_execute.c(501) :  Freeing 0x7FE0B786E070 (24 bytes), script=/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php
Last leak repeated 64 times
[Mon Feb  2 16:40:55 2015]  Script:  '/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php'
/home/vagrant/php-src/Zend/zend_vm_execute.h(26241) :  Freeing 0x7FE0B787C6C0 (64 bytes), script=/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php
Last leak repeated 4 times
[Mon Feb  2 16:40:55 2015]  Script:  '/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php'
/home/vagrant/php-src/Zend/zend_hash.c(1292) :  Freeing 0x7FE0B796B180 (288 bytes), script=/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php
/home/vagrant/php-src/Zend/zend_alloc.c(2247) : Actual location (location was relayed)
Last leak repeated 2 times
[Mon Feb  2 16:40:55 2015]  Script:  '/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php'
/home/vagrant/php-src/Zend/zend_string.h(97) :  Freeing 0x7FE0B79B1730 (40 bytes), script=/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php
[Mon Feb  2 16:40:55 2015]  Script:  '/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php'
/home/vagrant/php-src/Zend/zend_variables.c(247) :  Freeing 0x7FE0B7606480 (64 bytes), script=/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php
Last leak repeated 90 times
[Mon Feb  2 16:40:55 2015]  Script:  '/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php'
/home/vagrant/php-src/Zend/zend_hash.c(154) :  Freeing 0x7FE0B7607780 (256 bytes), script=/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php
/home/vagrant/php-src/Zend/zend_alloc.c(2247) : Actual location (location was relayed)
Last leak repeated 20 times
[Mon Feb  2 16:40:55 2015]  Script:  '/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php'
/home/vagrant/php-src/Zend/zend_hash.c(1249) :  Freeing 0x7FE0B76078C0 (256 bytes), script=/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php
/home/vagrant/php-src/Zend/zend_alloc.c(2247) : Actual location (location was relayed)
Last leak repeated 60 times
[Mon Feb  2 16:40:55 2015]  Script:  '/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php'
/home/vagrant/php-src/Zend/zend_hash.c(271) :  Freeing 0x7FE0B7608F40 (288 bytes), script=/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php
/home/vagrant/php-src/Zend/zend_alloc.c(2247) : Actual location (location was relayed)
Last leak repeated 5 times
[Mon Feb  2 16:40:55 2015]  Script:  '/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php'
/home/vagrant/php-src/Zend/zend_hash.c(422) :  Freeing 0x7FE0B760B9C0 (256 bytes), script=/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php
/home/vagrant/php-src/Zend/zend_alloc.c(2247) : Actual location (location was relayed)
Last leak repeated 5 times
[Mon Feb  2 16:40:55 2015]  Script:  '/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php'
/home/vagrant/php-src/Zend/zend_API.c(896) :  Freeing 0x7FE0B760C0C0 (64 bytes), script=/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php
Last leak repeated 21 times
[Mon Feb  2 16:40:55 2015]  Script:  '/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php'
/home/vagrant/php-src/Zend/zend_vm_execute.h(28517) :  Freeing 0x7FE0B7615420 (64 bytes), script=/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php
Last leak repeated 5 times
[Mon Feb  2 16:40:55 2015]  Script:  '/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php'
/home/vagrant/php-src/Zend/zend_string.h(165) :  Freeing 0x7FE0B7623580 (32 bytes), script=/home/vagrant/horde/framework/Routes/test/Horde/Routes/AllTests.php
Last leak repeated 4 times
=== Total 2263 memory leaks detected ===

$ valgrind --leak-check=full php framework/Routes/test/Horde/Routes/AllTests.php 
==23171== Memcheck, a memory error detector
==23171== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==23171== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==23171== Command: php framework/Routes/test/Horde/Routes/AllTests.php
==23171== 
PHPUnit 4.4.0 by Sebastian Bergmann.

...............................................................  63 / 127 ( 49%)
.........................................S.............==23171== Invalid read of size 1
==23171==    at 0xF9A18F1: ???
==23171==    by 0x5162C0: _pcre_jit_exec (pcre_jit_compile.c:10433)
==23171==    by 0x4E293F: php_pcre_exec (pcre_exec.c:6487)
==23171==    by 0x51A74D: php_pcre_replace_impl (php_pcre.c:1093)
==23171==    by 0x51A43E: php_pcre_replace (php_pcre.c:1003)
==23171==    by 0x51B0FF: php_replace_in_subject (php_pcre.c:1313)
==23171==    by 0x51BD44: preg_replace_impl (php_pcre.c:1410)
==23171==    by 0x51BE5E: zif_preg_replace (php_pcre.c:1430)
==23171==    by 0xAC1F22: ZEND_DO_FCALL_SPEC_HANDLER (zend_vm_execute.h:596)
==23171==    by 0xAC14C7: execute_ex (zend_vm_execute.h:352)
==23171==    by 0xA5BC23: zend_call_function (zend_execute_API.c:835)
==23171==    by 0x7F1C61: zim_reflection_method_invokeArgs (php_reflection.c:3079)
==23171==  Address 0xf4241 is not stack'd, malloc'd or (recently) free'd
==23171== 
==23171== 
==23171== Process terminating with default action of signal 11 (SIGSEGV)
==23171==  Access not within mapped region at address 0xF4241
==23171==    at 0xF9A18F1: ???
==23171==    by 0x5162C0: _pcre_jit_exec (pcre_jit_compile.c:10433)
==23171==    by 0x4E293F: php_pcre_exec (pcre_exec.c:6487)
==23171==    by 0x51A74D: php_pcre_replace_impl (php_pcre.c:1093)
==23171==    by 0x51A43E: php_pcre_replace (php_pcre.c:1003)
==23171==    by 0x51B0FF: php_replace_in_subject (php_pcre.c:1313)
==23171==    by 0x51BD44: preg_replace_impl (php_pcre.c:1410)
==23171==    by 0x51BE5E: zif_preg_replace (php_pcre.c:1430)
==23171==    by 0xAC1F22: ZEND_DO_FCALL_SPEC_HANDLER (zend_vm_execute.h:596)
==23171==    by 0xAC14C7: execute_ex (zend_vm_execute.h:352)
==23171==    by 0xA5BC23: zend_call_function (zend_execute_API.c:835)
==23171==    by 0x7F1C61: zim_reflection_method_invokeArgs (php_reflection.c:3079)
==23171==  If you believe this happened as a result of a stack
==23171==  overflow in your program's main thread (unlikely but
==23171==  possible), you can try to increase the size of the
==23171==  main thread stack using the --main-stacksize= flag.
==23171==  The main thread stack size used in this run was 8388608.
==23171== 
==23171== HEAP SUMMARY:
==23171==     in use at exit: 2,296,754 bytes in 21,620 blocks
==23171==   total heap usage: 27,734 allocs, 6,114 frees, 4,307,427 bytes allocated
==23171== 
==23171== LEAK SUMMARY:
==23171==    definitely lost: 0 bytes in 0 blocks
==23171==    indirectly lost: 0 bytes in 0 blocks
==23171==      possibly lost: 0 bytes in 0 blocks
==23171==    still reachable: 2,296,754 bytes in 21,620 blocks
==23171==         suppressed: 0 bytes in 0 blocks
==23171== Reachable blocks (those to which a pointer was found) are not shown.
==23171== To see them, rerun with: --leak-check=full --show-reachable=yes
==23171== 
==23171== For counts of detected and suppressed errors, rerun with: -v
==23171== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 30 from 6)
Segmentation fault



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-02-03 03:44 UTC] laruence@php.net
$ /home/huixinchen/local/php-trunk/bin/php framework/Routes/test/Horde/Routes/AllTests.php
PHP Warning:  require_once(Horde/Test/AllTests.php): failed to open stream: No such file or directory in /home/huixinchen/local/www/htdocs/horde/framework/Routes/test/Horde/Routes/AllTests.php on line 2

Warning: require_once(Horde/Test/AllTests.php): failed to open stream: No such file or directory in /home/huixinchen/local/www/htdocs/horde/framework/Routes/test/Horde/Routes/AllTests.php on line 2
PHP Fatal error:  require_once(): Failed opening required 'Horde/Test/AllTests.php' (include_path='.:/home/huixinchen/local/php-trunk/lib/php') in /home/huixinchen/local/www/htdocs/horde/framework/Routes/test/Horde/Routes/AllTests.php on line 2

Fatal error: require_once(): Failed opening required 'Horde/Test/AllTests.php' (include_path='.:/home/huixinchen/local/php-trunk/lib/php') in /home/huixinchen/local/www/htdocs/horde/framework/Routes/test/Horde/Routes/AllTests.php on line 2
 [2015-02-03 08:39 UTC] yunosh@php.net
Usually you would need to PEAR-install those package, but since PEAR is currently broken with PHP 7...
To workaround this, it's easiest to put all lib/ sub-directories of framework/ into the include_path.
 [2015-02-03 14:11 UTC] laruence@php.net
I think this may relates to this: https://github.com/php/php-src/blob/master/Zend/zend_gc.c#L494

it's a knew issue.. (must be fixed later)
 [2015-02-07 03:20 UTC] laruence@php.net
-Assigned To: +Assigned To: laruence
 [2016-03-20 18:20 UTC] nikic@php.net
-Status: Assigned +Status: Feedback
 [2016-03-20 18:20 UTC] nikic@php.net
Does this issue still exist?
 [2016-04-03 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 [2016-04-05 12:03 UTC] yunosh@php.net
-Status: No Feedback +Status: Closed
 [2016-04-05 12:03 UTC] yunosh@php.net
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 22:01:28 2024 UTC