summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2019-08-09 13:37:23 +0300
committerDmitry Stogov <dmitry@zend.com>2019-08-09 13:37:23 +0300
commit2e2cd65d7317d8a196d8e260a1a80dd06a226571 (patch)
treeae8ec14d5f2d71a6e09fc6de1776dbfb6815d242
parent796efd849e18e52659304a7e7836f3197a4fe177 (diff)
downloadphp-git-2e2cd65d7317d8a196d8e260a1a80dd06a226571.tar.gz
Added asserts to catch GC errors when refcount goes below zero.
-rw-r--r--Zend/zend_gc.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Zend/zend_gc.c b/Zend/zend_gc.c
index 47236a934e..30ca4d0a2a 100644
--- a/Zend/zend_gc.c
+++ b/Zend/zend_gc.c
@@ -507,6 +507,7 @@ tail_call:
while (zv != end) {
if (Z_REFCOUNTED_P(zv)) {
ref = Z_COUNTED_P(zv);
+ ZEND_ASSERT(GC_REFCOUNT(ref) > 0);
GC_REFCOUNT(ref)--;
gc_mark_grey(ref);
}
@@ -514,6 +515,7 @@ tail_call:
}
if (EXPECTED(!ht)) {
ref = Z_COUNTED_P(zv);
+ ZEND_ASSERT(GC_REFCOUNT(ref) > 0);
GC_REFCOUNT(ref)--;
goto tail_call;
}
@@ -530,6 +532,7 @@ tail_call:
} else if (GC_TYPE(ref) == IS_REFERENCE) {
if (Z_REFCOUNTED(((zend_reference*)ref)->val)) {
ref = Z_COUNTED(((zend_reference*)ref)->val);
+ ZEND_ASSERT(GC_REFCOUNT(ref) > 0);
GC_REFCOUNT(ref)--;
goto tail_call;
}
@@ -559,6 +562,7 @@ tail_call:
}
if (Z_REFCOUNTED_P(zv)) {
ref = Z_COUNTED_P(zv);
+ ZEND_ASSERT(GC_REFCOUNT(ref) > 0);
GC_REFCOUNT(ref)--;
gc_mark_grey(ref);
}
@@ -569,6 +573,7 @@ tail_call:
zv = Z_INDIRECT_P(zv);
}
ref = Z_COUNTED_P(zv);
+ ZEND_ASSERT(GC_REFCOUNT(ref) > 0);
GC_REFCOUNT(ref)--;
goto tail_call;
}