cvs: ZendEngine2(PHP_5_3) / zend_execute.c /tests bug32799.phpt bug39346.phpt php-src NEWS
| From: | Dmitry Stogov | Date: | Fri, 11 Jan 2008 08:42:06 +0000 |
| Subject: | cvs: ZendEngine2(PHP_5_3) / zend_execute.c /tests bug32799.phpt bug39346.phpt php-src NEWS | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-6259@lists.php.net to get a copy of this message | ||
dmitry Fri Jan 11 08:42:06 2008 UTC
Added files: (Branch: PHP_5_3)
/ZendEngine2/tests bug39346.phpt
Modified files:
/php-src NEWS
/ZendEngine2 zend_execute.c
/ZendEngine2/tests bug32799.phpt
Log:
Fixed bug #39346 (Unsetting a static variable inside a destructor causes segfault later on)
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.965.2.66&r2=1.2027.2.547.2.965.2.67&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.965.2.66 php-src/NEWS:1.2027.2.547.2.965.2.67
--- php-src/NEWS:1.2027.2.547.2.965.2.66 Wed Jan 9 14:27:31 2008
+++ php-src/NEWS Fri Jan 11 08:42:06 2008
@@ -91,6 +91,8 @@
- Fixed bug #39700 (NUMERIC error when result precision are 7,8 or 12-14 ).
(Lars W)
- Fixed bug #39397 (invalid statement handle in Unknown on line 0). (Lars W)
+- Fixed bug #39346 (Unsetting a static variable inside a destructor causes
+ segfault later on). (Dmitry)
- Fixed bug #39056 (Interbase NUMERIC data type error). (Lars W)
- Fixed bug #38468 (Unexpected creation of cycle). (Dmitry)
- Fixed bug #37911 (preg_replace_callback() ignores named groups). (Nuno)
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_execute.c?r1=1.716.2.12.2.24.2.11&r2=1.716.2.12.2.24.2.12&diff_format=u
Index: ZendEngine2/zend_execute.c
diff -u ZendEngine2/zend_execute.c:1.716.2.12.2.24.2.11
ZendEngine2/zend_execute.c:1.716.2.12.2.24.2.12
--- ZendEngine2/zend_execute.c:1.716.2.12.2.24.2.11 Mon Dec 31 07:17:04 2007
+++ ZendEngine2/zend_execute.c Fri Jan 11 08:42:06 2008
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_execute.c,v 1.716.2.12.2.24.2.11 2007/12/31 07:17:04 sebastian Exp $ */
+/* $Id: zend_execute.c,v 1.716.2.12.2.24.2.12 2008/01/11 08:42:06 dmitry Exp $ */
#define ZEND_INTENSIVE_DEBUGGING 0
@@ -691,6 +691,7 @@
static inline zval* zend_assign_to_variable(zval **variable_ptr_ptr, zval *value, int is_tmp_var
TSRMLS_DC)
{
zval *variable_ptr = *variable_ptr_ptr;
+ zval garbage;
if (variable_ptr == EG(error_zval_ptr)) {
if (is_tmp_var) {
@@ -716,7 +717,6 @@
} else if (PZVAL_IS_REF(variable_ptr)) {
if (variable_ptr != value) {
zend_uint refcount = Z_REFCOUNT_P(variable_ptr);
- zval garbage;
if (!is_tmp_var) {
Z_ADDREF_P(value);
@@ -756,7 +756,6 @@
} else if (PZVAL_IS_REF(variable_ptr)) {
if (variable_ptr!=value) {
zend_uint refcount = Z_REFCOUNT_P(variable_ptr);
- zval garbage;
if (!is_tmp_var) {
Z_ADDREF_P(value);
@@ -778,23 +777,25 @@
if (variable_ptr==value) {
Z_ADDREF_P(variable_ptr);
} else if (PZVAL_IS_REF(value)) {
- zval tmp;
-
- tmp = *value;
- zval_copy_ctor(&tmp);
- Z_SET_REFCOUNT(tmp, 1);
- zendi_zval_dtor(*variable_ptr);
- *variable_ptr = tmp;
+ garbage = *variable_ptr;
+ *variable_ptr = *value;
+ INIT_PZVAL(variable_ptr);
+ zval_copy_ctor(variable_ptr);
+ zendi_zval_dtor(garbage);
+ return variable_ptr;
} else {
Z_ADDREF_P(value);
+ *variable_ptr_ptr = value;
zendi_zval_dtor(*variable_ptr);
safe_free_zval_ptr(variable_ptr);
- *variable_ptr_ptr = value;
+ return value;
}
} else {
- zendi_zval_dtor(*variable_ptr);
- Z_SET_REFCOUNT_P(value, 1);
+ garbage = *variable_ptr;
*variable_ptr = *value;
+ INIT_PZVAL(variable_ptr);
+ zendi_zval_dtor(garbage);
+ return variable_ptr;
}
} else { /* we need to split */
if (!is_tmp_var) {
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug32799.phpt?r1=1.2&r2=1.2.6.1&diff_format=u
Index: ZendEngine2/tests/bug32799.phpt
diff -u ZendEngine2/tests/bug32799.phpt:1.2 ZendEngine2/tests/bug32799.phpt:1.2.6.1
--- ZendEngine2/tests/bug32799.phpt:1.2 Mon Jun 6 10:38:43 2005
+++ ZendEngine2/tests/bug32799.phpt Fri Jan 11 08:42:06 2008
@@ -5,17 +5,17 @@
class test{
public $c=1;
function __destruct (){
- $GLOBALS['p']->c++; // no warning
- print $GLOBALS['p']->c."\n"; // segfault
- var_dump($GLOBALS['p']);
+ if (!isset($GLOBALS['p'])) {
+ echo "NULL\n";
+ } else {
+ $GLOBALS['p']->c++; // no warning
+ print $GLOBALS['p']->c."\n"; // segfault
+ var_dump($GLOBALS['p']);
+ }
}
}
$p=new test;
$p=null; //destroy the object by a new assignment (segfault)
?>
--EXPECT--
-2
-object(test)#1 (1) {
- ["c"]=>
- int(2)
-}
+NULL
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug39346.phpt?view=markup&rev=1.1
Index: ZendEngine2/tests/bug39346.phpt
+++ ZendEngine2/tests/bug39346.phpt