php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57515 memory exhausted
Submitted: 2007-02-08 06:17 UTC Modified: 2007-12-27 16:16 UTC
From: proofek at gmail dot com Assigned:
Status: Closed Package: runkit (PECL)
PHP Version: 5.2.0 OS: Linux (Debian)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: proofek at gmail dot com
New email:
PHP Version: OS:

 

 [2007-02-08 06:17 UTC] proofek at gmail dot com
Description:
------------
When I'm manipulating with class methods I get:

Fatal error: Allowed memory size of 524288000 bytes exhausted (tried to allocate 1680829573 bytes)

It happens during restoring original method.

The class is not small but it's not huge either.

Increasing allowed memory size didn't help.

Reproduce code:
---------------
runkit_method_copy('Class1', 'addFile', 'Class2', 'addFile');


(...) doing some stuff, and then


runkit_method_remove('Class2', 'addFile');

runkit_method_copy('Class2', 'addFile', 'Class1', 'addFile');

runkit_method_remove('Class1', 'addFile');

Expected result:
----------------
Run till the very end

Actual result:
--------------
Fatal error: Allowed memory size of 524288000 bytes exhausted (tried to allocate 1680829573 bytes)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-12-27 12:23 UTC] pecl at stefan-marr dot de
This occurs due to a bug in php_runkit_function_copy_ctor. There is dupvars initalization for the vars name missing.

Patch is following:

Index: runkit_functions.c
===================================================================
RCS file: /repository/pecl/runkit/runkit_functions.c,v
retrieving revision 1.10
diff -u -r1.10 runkit_functions.c
--- runkit_functions.c	17 Nov 2007 07:40:47 -0000	1.10
+++ runkit_functions.c	27 Dec 2007 17:22:31 -0000
@@ -136,6 +136,8 @@
 	while (i > 0) {
 		i--;
 		dupvars[i].name = estrdup(fe->op_array.vars[i].name);
+		dupvars[i].name_len = fe->op_array.vars[i].name_len;
+		dupvars[i].hash_value = fe->op_array.vars[i].hash_value;
 	}
 	fe->op_array.vars = dupvars;
 #endif
Index: tests/bug10053.phpt
===================================================================
RCS file: tests/bug10053.phpt
diff -N tests/bug10053.phpt
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/bug10053.phpt	27 Dec 2007 17:22:31 -0000
@@ -0,0 +1,65 @@
+--TEST--
+runkit_method_copy() function
+--SKIPIF--
+<?php if(!extension_loaded("runkit") || !RUNKIT_FEATURE_MANIPULATION) print "skip"; ?>
+--INI--
+error_reporting=E_ALL
+display_errors=on
+--FILE--
+<?php
+class runkit_one {
+	private $b = 0;
+	private $c = 1;
+	
+	function runkit_method($naturalNumber) {
+		$delta = $this->c + $naturalNumber;
+		$thisIsAStrangeVariableWithAVeryLongNameHopeThisWillShowTheError = $delta * $delta;
+		$objectVarWithLongName = new stdclass;
+		$objectVarWithLongName->e = $thisIsAStrangeVariableWithAVeryLongNameHopeThisWillShowTheError;
+		echo "Runkit Method: $naturalNumber\n";
+		var_dump($objectVarWithLongName);
+	}
+}
+
+class runkit_two {
+	private $b = 27;
+	private $c = 99;
+
+}
+
+$o = new runkit_one();
+$o->runkit_method(1);
+
+runkit_method_copy('runkit_two','runkit_method','runkit_one');
+
+$o->runkit_method(2);
+
+$o2 = new runkit_two();
+$o2->runkit_method(3);
+runkit_method_remove('runkit_one','runkit_method');
+if (method_exists('runkit_one','runkit_method')) {
+	echo "Runkit Method still exists in Runkit One!\n";
+}
+$o2->runkit_method(4);
+?>
+--EXPECT--
+Runkit Method: 1
+object(stdClass)#2 (1) {
+  ["e"]=>
+  int(4)
+}
+Runkit Method: 2
+object(stdClass)#2 (1) {
+  ["e"]=>
+  int(9)
+}
+Runkit Method: 3
+object(stdClass)#3 (1) {
+  ["e"]=>
+  int(10404)
+}
+Runkit Method: 4
+object(stdClass)#3 (1) {
+  ["e"]=>
+  int(10609)
+}
 [2007-12-27 16:16 UTC] sb at sebastian-bergmann dot de
This bug has been fixed in CVS.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pecl.php.net.

In case this was a pecl.php.net website problem, the change will show
up on the website in short time.
 
Thank you for the report, and for helping us make PECL better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 04:01:31 2024 UTC