Skip to content

Commit 7572d9b

Browse files
committed
Fix RC_DEBUG check for IS_NULL type
IS_NULL is set during GC, conservatively assume that it might have been an object.
1 parent bca1ebf commit 7572d9b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Zend/zend_types.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,10 +1143,15 @@ static zend_always_inline uint32_t zval_gc_info(uint32_t gc_type_info) {
11431143

11441144
#if ZEND_RC_DEBUG
11451145
extern ZEND_API bool zend_rc_debug;
1146+
/* The GC_PERSISTENT flag is reused for IS_OBJ_WEAKLY_REFERENCED on objects.
1147+
* Skip checks for OBJECT/NULL type to avoid interpreting the flag incorrectly. */
11461148
# define ZEND_RC_MOD_CHECK(p) do { \
1147-
if (zend_rc_debug && zval_gc_type((p)->u.type_info) != IS_OBJECT) { \
1148-
ZEND_ASSERT(!(zval_gc_flags((p)->u.type_info) & GC_IMMUTABLE)); \
1149-
ZEND_ASSERT((zval_gc_flags((p)->u.type_info) & (GC_PERSISTENT|GC_PERSISTENT_LOCAL)) != GC_PERSISTENT); \
1149+
if (zend_rc_debug) { \
1150+
zend_uchar type = zval_gc_type((p)->u.type_info); \
1151+
if (type != IS_OBJECT && type != IS_NULL) { \
1152+
ZEND_ASSERT(!(zval_gc_flags((p)->u.type_info) & GC_IMMUTABLE)); \
1153+
ZEND_ASSERT((zval_gc_flags((p)->u.type_info) & (GC_PERSISTENT|GC_PERSISTENT_LOCAL)) != GC_PERSISTENT); \
1154+
} \
11501155
} \
11511156
} while (0)
11521157
# define GC_MAKE_PERSISTENT_LOCAL(p) do { \

0 commit comments

Comments
 (0)