|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 04:00:01 2025 UTC |
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