php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24884 calling $this->__clone(); crashes php
Submitted: 2003-07-31 09:40 UTC Modified: 2003-08-04 04:11 UTC
From: auroraeosrose at hotmail dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2003-08-02 (dev) OS: *
Private report: No CVE-ID: None
 [2003-07-31 09:40 UTC] auroraeosrose at hotmail dot com
Description:
------------
calling $this->__clone(); inside a class crashes php

Latest CVS snapshot, apache 2 filter, gd, mbstring, and mysql dlls

Reason for calling it is attempting to create a backward compatible solution for cloning objects without a 5 ini setting change or seperate 4 and 5 codebases

Reproduce code:
---------------
<?php
class Test {
	function __copy()
	{
		$string = PHP_VERSION;
		$version = $string{0};
		if($string < 5)
		{
			return $this;
		}
		else
		{
			return $this->__clone();
		}
	}
}
$test = new Test();
$test2 = $test->__copy();
?>

Expected result:
----------------
If using php4, a copy of the object will be returned, if using php5, the current object should be cloned and returned.

Actual result:
--------------
php and apache die
actually calling $this->__clone(); anywhere in a class crashes  

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-08-01 20:48 UTC] sniper@php.net
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1024 (runnable)]
0x8381fd4 in zend_clone_handler (execute_data=0xbfffd1ec, op_array=0x41c760b0)
    at /usr/src/web/php/php5/Zend/zend_execute.c:3042
3042            if (Z_TYPE_P(obj) != IS_OBJECT) {
(gdb) bt
#0  0x8381fd4 in zend_clone_handler (execute_data=0xbfffd1ec, op_array=0x41c760b0)
    at /usr/src/web/php/php5/Zend/zend_execute.c:3042
#1  0x837b22b in execute (op_array=0x41c760b0) at /usr/src/web/php/php5/Zend/zend_execute.c:1199
#2  0x8380278 in zend_do_fcall_common_helper (execute_data=0xbfffd4dc, op_array=0x41c72d60)
    at /usr/src/web/php/php5/Zend/zend_execute.c:2529
#3  0x83806ee in zend_do_fcall_by_name_handler (execute_data=0xbfffd4dc, op_array=0x41c72d60)
    at /usr/src/web/php/php5/Zend/zend_execute.c:2602
#4  0x837b22b in execute (op_array=0x41c72d60) at /usr/src/web/php/php5/Zend/zend_execute.c:1199
#5  0x835a174 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /usr/src/web/php/php5/Zend/zend.c:1032
#6  0x8313b6e in php_execute_script (primary_file=0xbffff870) at /usr/src/web/php/php5/main/main.c:1573
#7  0x83959df in main (argc=3, argv=0xbffff8e4) at /usr/src/web/php/php5/sapi/cli/php_cli.c:910
#8  0x4055b9cb in __libc_start_main (main=0x8394c04 <main>, argc=3, argv=0xbffff8e4, init=0x80b5b6c <_init>, 
    fini=0x84f3f94 <_fini>, rtld_fini=0x4000aea0 <_dl_fini>, stack_end=0xbffff8dc)
    at ../sysdeps/generic/libc-start.c:92

 [2003-08-04 04:11 UTC] stas@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 Sep 19 07:01:27 2024 UTC