com php-src: Merge branch 'PHP-7.1': Zend/zend_gc.c Zend/ zend_gc.h

[email protected] (Xinchen Hui)
Newsgroups php.cvs
Message-ID <[email protected]>
Commit:    00e5ea7b76f7af4ae9b6457096b4a9d309ee1203
Author:    Xinchen Hui <[email protected]>         Mon, 13 Feb 2017 19:24:00 +0800
Parents:   91159bdcf54ad4e4b606b5869bab977b6ba042dd 930ce02048471361bd0016ebf99d26bc5fdb4d04
Branches:  master

Link:       http://git.php.net/?p=php-src.git;a=commitdiff;h=00e5ea7b76f7af4ae9b6457096b4a9d309ee1203

Log:
Merge branch 'PHP-7.1'

* PHP-7.1:
  Update NEWS
  Fixed bug  #73989 (PHP 7.1 Segfaults within Symfony test suite)

Conflicts:
	Zend/zend_gc.c

Bugs:
https://bugs.php.net/73989

Changed paths:
  MM  Zend/zend_gc.c
  MM  Zend/zend_gc.h


Diff:
diff --cc Zend/zend_gc.c
index 9d1a9e4,087f04b..5aaef4f
--- a/Zend/zend_gc.c
+++ b/Zend/zend_gc.c
@@@ -1084,44 -1108,45 +1103,44 @@@ ZEND_API int zend_gc_collect_cycles(voi
  
  		if (gc_flags & GC_HAS_DESTRUCTORS) {
  			GC_TRACE("Calling destructors");
 -			if (EG(objects_store).object_buckets) {
 -				/* Remember reference counters before calling destructors */
 -				current = to_free.next;
 -				while (current != &to_free) {
 -					current->refcount = GC_REFCOUNT(current->ref);
 -					current = current->next;
 -				}
  
 -				/* Call destructors */
 -				current = to_free.next;
 -				while (current != &to_free) {
 -					p = current->ref;
 -					GC_G(next_to_free) = current->next;
 -					if (GC_TYPE(p) == IS_OBJECT) {
 -						zend_object *obj = (zend_object*)p;
 -
 -						if (IS_OBJ_VALID(EG(objects_store).object_buckets[obj->handle]) &&
 -							!(GC_FLAGS(obj) & IS_OBJ_DESTRUCTOR_CALLED)) {
 -							GC_TRACE_REF(obj, "calling destructor");
 -							GC_FLAGS(obj) |= IS_OBJ_DESTRUCTOR_CALLED;
 -							if (obj->handlers->dtor_obj) {
 -								GC_REFCOUNT(obj)++;
 -								obj->handlers->dtor_obj(obj);
 -								GC_REFCOUNT(obj)--;
 -							}
 +			/* Remember reference counters before calling destructors */
 +			current = to_free.next;
 +			while (current != &to_free) {
 +				current->refcount = GC_REFCOUNT(current->ref);
 +				current = current->next;
 +			}
 +
 +			/* Call destructors */
 +			current = to_free.next;
 +			while (current != &to_free) {
 +				p = current->ref;
 +				GC_G(next_to_free) = current->next;
- 				if ((GC_TYPE(p) & GC_TYPE_MASK) == IS_OBJECT) {
++				if (GC_TYPE(p) == IS_OBJECT) {
 +					zend_object *obj = (zend_object*)p;
 +
 +					if (IS_OBJ_VALID(EG(objects_store).object_buckets[obj->handle]) &&
 +						!(GC_FLAGS(obj) & IS_OBJ_DESTRUCTOR_CALLED)) {
 +						GC_TRACE_REF(obj, "calling destructor");
 +						GC_FLAGS(obj) |= IS_OBJ_DESTRUCTOR_CALLED;
 +						if (obj->handlers->dtor_obj) {
 +							GC_REFCOUNT(obj)++;
 +							obj->handlers->dtor_obj(obj);
 +							GC_REFCOUNT(obj)--;
  						}
  					}
 -					current = GC_G(next_to_free);
  				}
 +				current = GC_G(next_to_free);
 +			}
  
 -				/* Remove values captured in destructors */
 -				current = to_free.next;
 -				while (current != &to_free) {
 -					GC_G(next_to_free) = current->next;
 -					if (GC_REFCOUNT(current->ref) > current->refcount) {
 -						gc_remove_nested_data_from_buffer(current->ref, current);
 -					}
 -					current = GC_G(next_to_free);
 +			/* Remove values captured in destructors */
 +			current = to_free.next;
 +			while (current != &to_free) {
 +				GC_G(next_to_free) = current->next;
 +				if (GC_REFCOUNT(current->ref) > current->refcount) {
 +					gc_remove_nested_data_from_buffer(current->ref, current);
  				}
 +				current = GC_G(next_to_free);
  			}
  		}
  
@@@ -1133,10 -1158,11 +1152,10 @@@
  			p = current->ref;
  			GC_G(next_to_free) = current->next;
  			GC_TRACE_REF(p, "destroying");
- 			if ((GC_TYPE(p) & GC_TYPE_MASK) == IS_OBJECT) {
+ 			if (GC_TYPE(p) == IS_OBJECT) {
  				zend_object *obj = (zend_object*)p;
  
 -				if (EG(objects_store).object_buckets &&
 -				    IS_OBJ_VALID(EG(objects_store).object_buckets[obj->handle])) {
 +				if (IS_OBJ_VALID(EG(objects_store).object_buckets[obj->handle])) {
  					EG(objects_store).object_buckets[obj->handle] = SET_OBJ_INVALID(obj);
  					GC_TYPE(obj) = IS_NULL;
  					if (!(GC_FLAGS(obj) & IS_OBJ_FREE_CALLED)) {
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.