cvs: ZendEngine2 / zend_gc.c /tests gc_029.phpt gc_030.phpt

"Dmitry Stogov" <[email protected]>
Newsgroups gmane.comp.php.cvs.zend
Message-ID <cvsdmitry1215504978@cvsserver>
dmitry		Tue Jul  8 08:16:18 2008 UTC

  Modified files:              
    /ZendEngine2	zend_gc.c 
    /ZendEngine2/tests	gc_030.phpt gc_029.phpt 
  Log:
  Fixed bug #45434 (circular reference causes segfault in gc_collect_cycles())
  
  
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_gc.c?r1=1.14&r2=1.15&diff_format=u
Index: ZendEngine2/zend_gc.c
diff -u ZendEngine2/zend_gc.c:1.14 ZendEngine2/zend_gc.c:1.15
--- ZendEngine2/zend_gc.c:1.14	Tue Apr 29 13:50:22 2008
+++ ZendEngine2/zend_gc.c	Tue Jul  8 08:16:18 2008
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_gc.c,v 1.14 2008/04/29 13:50:22 tony2001 Exp $ */
+/* $Id: zend_gc.c,v 1.15 2008/07/08 08:16:18 dmitry Exp $ */
 
 #include "zend.h"
 #include "zend_API.h"
@@ -553,9 +553,9 @@
 					!EG(objects_store).object_buckets[Z_OBJ_HANDLE(p->z)].destructor_called) {
 
 					EG(objects_store).object_buckets[Z_OBJ_HANDLE(p->z)].destructor_called = 1;
-					zend_try {
-						EG(objects_store).object_buckets[Z_OBJ_HANDLE(p->z)].bucket.obj.dtor(EG(objects_store).object_buckets[Z_OBJ_HANDLE(p->z)].bucket.obj.object, Z_OBJ_HANDLE(p->z) TSRMLS_CC);
-					} zend_end_try();
+					EG(objects_store).object_buckets[Z_OBJ_HANDLE(p->z)].bucket.obj.refcount++;
+					EG(objects_store).object_buckets[Z_OBJ_HANDLE(p->z)].bucket.obj.dtor(EG(objects_store).object_buckets[Z_OBJ_HANDLE(p->z)].bucket.obj.object, Z_OBJ_HANDLE(p->z) TSRMLS_CC);
+					EG(objects_store).object_buckets[Z_OBJ_HANDLE(p->z)].bucket.obj.refcount--;
 				}
 			}
 			count++;
@@ -571,19 +571,15 @@
 					EG(objects_store).object_buckets[Z_OBJ_HANDLE(p->z)].valid &&
 					EG(objects_store).object_buckets[Z_OBJ_HANDLE(p->z)].bucket.obj.refcount <= 0) {
 					EG(objects_store).object_buckets[Z_OBJ_HANDLE(p->z)].bucket.obj.refcount = 1;
-					zend_try {
-						Z_TYPE(p->z) = IS_NULL;
-						zend_objects_store_del_ref_by_handle(Z_OBJ_HANDLE(p->z) TSRMLS_CC);
-					} zend_end_try();
+					Z_TYPE(p->z) = IS_NULL;
+					zend_objects_store_del_ref_by_handle(Z_OBJ_HANDLE(p->z) TSRMLS_CC);
 				}
 			} else if (Z_TYPE(p->z) == IS_ARRAY) {
 				Z_TYPE(p->z) = IS_NULL;
 				zend_hash_destroy(Z_ARRVAL(p->z));
 				FREE_HASHTABLE(Z_ARRVAL(p->z));
 			} else {
-				zend_try {
-					zval_dtor(&p->z);
-				} zend_end_try();
+				zval_dtor(&p->z);
 				Z_TYPE(p->z) = IS_NULL;
 			}
 			p = GC_G(next_to_free);
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/gc_030.phpt?r1=1.1&r2=1.2&diff_format=u
Index: ZendEngine2/tests/gc_030.phpt
diff -u /dev/null ZendEngine2/tests/gc_030.phpt:1.2
--- /dev/null	Tue Jul  8 08:16:18 2008
+++ ZendEngine2/tests/gc_030.phpt	Tue Jul  8 08:16:18 2008
@@ -0,0 +1,21 @@
+--TEST--
+GC 030: GC and exceptions in destructors
+--FILE--
+<?php
+class foo {
+    public $foo;
+
+    public function __destruct() {
+        throw new Exception("foobar");
+    }
+}
+
+$f1 = new foo;
+$f2 = new foo;
+$f1->foo = $f2;
+$f2->foo = $f1;
+unset($f1, $f2);
+gc_collect_cycles();
+?>
+--EXPECTF--
+Fatal error: Ignoring exception from foo::__destruct() while an exception is already active (Uncaught Exception in %sgc_030.php on line %d) in %sgc_030.php on line %d
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/gc_029.phpt?r1=1.2&r2=1.3&diff_format=u
Index: ZendEngine2/tests/gc_029.phpt
diff -u ZendEngine2/tests/gc_029.phpt:1.2 ZendEngine2/tests/gc_029.phpt:1.3
--- ZendEngine2/tests/gc_029.phpt:1.2	Fri Mar 14 18:37:17 2008
+++ ZendEngine2/tests/gc_029.phpt	Tue Jul  8 08:16:18 2008
@@ -1,5 +1,5 @@
 --TEST--
-GC 028: GC and destructors
+GC 029: GC and destructors
 --FILE--
 <?php
 class Foo {



-- 
Zend Engine CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.