Skip to content

Commit

Permalink
Merge branch 'PHP-5.5' into PHP-5.6
Browse files Browse the repository at this point in the history
* PHP-5.5:
  Prevent GC from changing zval or object 'color' before they are actually inserted into possible roots buffer.
  • Loading branch information
dstogov committed Apr 2, 2015
2 parents 9712304 + f29c98c commit baf5fdf
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions Zend/zend_gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,6 @@ ZEND_API void gc_zval_possible_root(zval *zv TSRMLS_DC)
GC_BENCH_INC(zval_possible_root);

if (GC_ZVAL_GET_COLOR(zv) != GC_PURPLE) {
GC_ZVAL_SET_PURPLE(zv);

if (!GC_ZVAL_ADDRESS(zv)) {
gc_root_buffer *newRoot = GC_G(unused);

Expand All @@ -159,7 +157,6 @@ ZEND_API void gc_zval_possible_root(zval *zv TSRMLS_DC)
GC_G(first_unused)++;
} else {
if (!GC_G(gc_enabled)) {
GC_ZVAL_SET_BLACK(zv);
return;
}
zv->refcount__gc++;
Expand All @@ -169,10 +166,10 @@ ZEND_API void gc_zval_possible_root(zval *zv TSRMLS_DC)
if (!newRoot) {
return;
}
GC_ZVAL_SET_PURPLE(zv);
GC_G(unused) = newRoot->prev;
}

GC_ZVAL_SET_PURPLE(zv);
newRoot->next = GC_G(roots).next;
newRoot->prev = &GC_G(roots);
GC_G(roots).next->prev = newRoot;
Expand Down Expand Up @@ -203,7 +200,6 @@ ZEND_API void gc_zobj_possible_root(zval *zv TSRMLS_DC)

obj = &EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(zv)].bucket.obj;
if (GC_GET_COLOR(obj->buffered) != GC_PURPLE) {
GC_SET_PURPLE(obj->buffered);
if (!GC_ADDRESS(obj->buffered)) {
gc_root_buffer *newRoot = GC_G(unused);

Expand All @@ -214,7 +210,6 @@ ZEND_API void gc_zobj_possible_root(zval *zv TSRMLS_DC)
GC_G(first_unused)++;
} else {
if (!GC_G(gc_enabled)) {
GC_ZVAL_SET_BLACK(zv);
return;
}
zv->refcount__gc++;
Expand All @@ -225,10 +220,10 @@ ZEND_API void gc_zobj_possible_root(zval *zv TSRMLS_DC)
return;
}
obj = &EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(zv)].bucket.obj;
GC_SET_PURPLE(obj->buffered);
GC_G(unused) = newRoot->prev;
}

GC_SET_PURPLE(obj->buffered);
newRoot->next = GC_G(roots).next;
newRoot->prev = &GC_G(roots);
GC_G(roots).next->prev = newRoot;
Expand Down

0 comments on commit baf5fdf

Please sign in to comment.