php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46960 Actual location (location was relayed)
Submitted: 2008-12-28 08:37 UTC Modified: 2009-01-11 09:22 UTC
From: rutekp at freelance-worker dot net Assigned: dmitry (profile)
Status: Closed Package: Reproducible crash
PHP Version: 5.2.8 OS: Centos 5 x64
Private report: No CVE-ID: None
 [2008-12-28 08:37 UTC] rutekp at freelance-worker dot net
Description:
------------
When I try to excedue code which is below without:
$array["foo"] = null;
$array["blah"] = null;

have errors like 
Actual location (location was relayed)
Freeing 0x05298E00



Reproduce code:
---------------
--TEST--
Test session_encode() function : variation
--SKIPIF--
<?php include('skipif.inc'); ?>
--FILE--
<?php

ob_start();
echo "*** Testing session_encode() : variation ***\n";
var_dump(session_start());
$array = array(1,2,3);
$array["foo"] = &$array;
$array["blah"] = &$array;
$_SESSION["data"] = &$array;
var_dump(session_encode());
var_dump(session_destroy());
echo "Done";
ob_end_flush();
?>
--EXPECTF--
*** Testing session_encode() : variation ***
bool(true)
string(64) 
"data|a:5:{i:0;i:1;i:1;i:2;i:2;i:3;s:3:"foo";R:1;s:4:"blah";R:1;}"
bool(true)
Done


Actual result:
--------------
[Thu Oct 30 20:56:43 2008]  Script:  'ext/session/tests/session_encode_variation5.phpt'
/root/src/php-5.2.6/Zend/zend_vm_execute.h(3565) :  Freeing 0x05293DD8 (24 bytes), script=ext/session/tests/session_encode_variation5.phpt
Last leak repeated 2 times
[Thu Oct 30 20:56:43 2008]  Script:  'ext/session/tests/session_encode_variation5.phpt'
/root/src/php-5.2.6/Zend/zend_vm_execute.h(3610) :  Freeing 0x05298CC8 (72 bytes), script=ext/session/tests/session_encode_variation5.phpt
/root/src/php-5.2.6/Zend/zend_API.c(827) : Actual location (location was relayed)
Last leak repeated 1 time
[Thu Oct 30 20:56:43 2008]  Script:  'ext/session/tests/session_encode_variation5.phpt'
/root/src/php-5.2.6/Zend/zend_vm_execute.h(3596) :  Freeing 0x05298E00 (71 bytes), script=ext/session/tests/session_encode_variation5.phpt
/root/src/php-5.2.6/Zend/zend_hash.c(388) : Actual location (location was relayed)
Last leak repeated 2 times
[Thu Oct 30 20:56:43 2008]  Script:  'ext/session/tests/session_encode_variation5.phpt'
/root/src/php-5.2.6/Zend/zend_execute.c(834) :  Freeing 0x05299050 (24 bytes), script=ext/session/tests/session_encode_variation5.phpt
[Thu Oct 30 20:56:43 2008]  Script:  'ext/session/tests/session_encode_variation5.phpt'
/root/src/php-5.2.6/Zend/zend_hash.c(247) :  Freeing 0x052990C0 (75 bytes), script=ext/session/tests/session_encode_variation5.phpt
Last leak repeated 1 time
=== Total 11 memory leaks detected ===

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-01-11 09:22 UTC] dmitry@php.net
This bug has been fixed in CVS.

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/.
 
Thank you for the report, and for helping us make PHP better.

The bug is already fixed in PHP-5.3 with Garbage Collector which collects cyclic references. In PHP-5.2 this bug will never fixed.

You can get the same memory leaks with smaller script:

<?php
$array = array(1,2,3);
$array["foo"] = &$array;
$array["blah"] = &$array;
?>

In case your script creates cyclic structures, in 5.2 it's better to break cycles before exit manually.

<?php
$array = array(1,2,3);
$array["foo"] = &$array;
$array["blah"] = &$array;
$array["foo"] = null;
$array["blah"] = null;
?>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 28 15:01:31 2024 UTC