php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31360 Maybe Array operation has some bug
Submitted: 2004-12-31 02:40 UTC Modified: 2004-12-31 08:40 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: tokimeki at 1111 dot com dot tw Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5.0.3 OS: FreeBSD / Windows XP
Private report: No CVE-ID: None
 [2004-12-31 02:40 UTC] tokimeki at 1111 dot com dot tw
Description:
------------
look the two source, index.php and debug.php.
At index.php (line 29), after array copy, and call show_var to show $arr or $test, I get a error.


Reproduce code:
---------------
http://timteam.org/?TIM=FORUM&FORUM=1&ShowDocument=12961#TIM12961

Expected result:
----------------
ok
(array) = {
	obj (object) = {}
	str (string) = str
	arr (array) = {}
	number (integer) = 100
	bool (boolean) = 1
	null (NULL) = 
	test (array) = {
		AAA (string) = 000
		BBB (array) = {
			zzz (string) = Z
			xxx (array) = {
				zzz (string) = Z
				xxx (array) -> (@[test][BBB][xxx])
			}
			yyy (array) = {
				www (array) -> (@[test][BBB])
				vvv (array) -> (@[test][BBB])
			}
		}
		CCC (array) -> (@)
		DDD (string) = ABC
		EEE (array) -> (@[test][BBB][yyy])
		FFF (array) -> (@[test][BBB])
		<>[]!@#$%^&*()_+|~`\:;,.? (array) = {
			TEST (string) = <>[]!@#$%^&*()_+|~`\:;,.?
		}
		  (array) -> (@[test][<>[]!@#$%^&*()_+|~`\:;,.?])
	}
}



Actual result:
--------------
ok
Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 128 bytes) in /home/tokimeki/public_html/test/debug.php on line 29

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-12-31 03:41 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Increase the memory limit, in your code you end up duplicating lot's of data which causes this limit to be reached.
 [2004-12-31 04:34 UTC] tokimeki at 1111 dot com dot tw
I already change the setting (memory_limit = 128M) in php.ini, But it has the same error.
I think that: $arr is a recursive array, so the operation maybe have some different!
Notice that, if I remark line 29, and call sohw_var twice, it's ok! So, this is a error.
Could you tell me, how many memory is enogth?
Thank you!
 [2004-12-31 06:03 UTC] tokimeki at 1111 dot com dot tw
I'm sorry! I already find the problem.
That is the serialize function which can't serialize a recursive array~~~
 [2004-12-31 08:40 UTC] tokimeki at 1111 dot com dot tw
I find a solution.
use this function to replace array copy.
ex: $test = clone($arr); // replace $test = $arr;

function & clone(&$var) {
	return $var;
}
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 16:01:36 2024 UTC