php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19269 PEAR.php - memory eating bug
Submitted: 2002-09-06 13:53 UTC Modified: 2002-09-25 12:41 UTC
From: wolfram at kriesing dot de Assigned:
Status: Closed Package: PEAR related
PHP Version: 4CVS-2002-09-06 OS: Any
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: wolfram at kriesing dot de
New email:
PHP Version: OS:

 

 [2002-09-06 13:53 UTC] wolfram at kriesing dot de
i am working on a big import script and just for fun i checked the size of $GLOBALS on every turn, and i realized it grew constantly, i found out that
       pushErrorHandling
pushes 2 elements on the array _PEAR_error_handler_stack, but
       popErrorHandling
pop's only one off the array, so it grows on every use!

and since those are used in DB/mysql.php and File/CSV.php my memory limit comes closer with every run through the while-loop

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-09-18 10:19 UTC] mj@php.net
Could you please try if the following patch (untested) works for you?

Index: PEAR.php
===================================================================
RCS file: /repository/php4/pear/PEAR.php,v
retrieving revision 1.47
diff -u -r1.47 PEAR.php
--- PEAR.php    21 Jul 2002 07:04:45 -0000      1.47
+++ PEAR.php    18 Sep 2002 15:15:50 -0000
@@ -582,7 +582,8 @@
     {
         $stack = &$GLOBALS['_PEAR_error_handler_stack'];
         array_pop($stack);
-        list($mode, $options) = $stack[sizeof($stack) - 1];
+        array_pop($stack);
+        list($mode, $options) = $stack[sizeof($stack)];
         if (isset($this)) {
             $this->setErrorHandling($mode, $options);
         } else {

 [2002-09-18 11:52 UTC] jrust at rustyparts dot com
The problem with that solution is that if pushErrorHandling() has been called only once before popErrorHandling then after both array_pops are done there is nothing left in the stack to do list() on and thus the following error occurs:
NOTICE (0x08) in /usr/share/php-pear/PEAR.php on line 492
Undefined offset: 0

Maybe the list() part should be done before the 2nd array_pop?  Or is there a need for always putting both the default mode and the passed in mode onto the stack?
 [2002-09-24 17:44 UTC] jrust at rustyparts dot com
This solution works.  It  just takes off the extra error mode after we're done using it.
--- PEAR2.php   Tue Sep 24 15:33:18 2002
+++ PEAR.php    Tue Sep 24 15:35:24 2002
@@ -583,6 +583,7 @@
         $stack = &$GLOBALS['_PEAR_error_handler_stack'];
         array_pop($stack);
         list($mode, $options) = $stack[sizeof($stack) - 1];
+        array_pop($stack);
         if (isset($this)) {
             $this->setErrorHandling($mode, $options);
         } else {
 [2002-09-25 12:41 UTC] mj@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, 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/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
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 Mar 28 23:01:26 2024 UTC