Skip to content

Commit

Permalink
Fix RC_DEBUG check for IS_NULL type
Browse files Browse the repository at this point in the history
IS_NULL is set during GC, conservatively assume that it might have
been an object.
  • Loading branch information
nikic committed Jul 20, 2021
1 parent bca1ebf commit 7572d9b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Zend/zend_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -1143,10 +1143,15 @@ static zend_always_inline uint32_t zval_gc_info(uint32_t gc_type_info) {

#if ZEND_RC_DEBUG
extern ZEND_API bool zend_rc_debug;
/* The GC_PERSISTENT flag is reused for IS_OBJ_WEAKLY_REFERENCED on objects.
* Skip checks for OBJECT/NULL type to avoid interpreting the flag incorrectly. */
# define ZEND_RC_MOD_CHECK(p) do { \
if (zend_rc_debug && zval_gc_type((p)->u.type_info) != IS_OBJECT) { \
ZEND_ASSERT(!(zval_gc_flags((p)->u.type_info) & GC_IMMUTABLE)); \
ZEND_ASSERT((zval_gc_flags((p)->u.type_info) & (GC_PERSISTENT|GC_PERSISTENT_LOCAL)) != GC_PERSISTENT); \
if (zend_rc_debug) { \
zend_uchar type = zval_gc_type((p)->u.type_info); \
if (type != IS_OBJECT && type != IS_NULL) { \
ZEND_ASSERT(!(zval_gc_flags((p)->u.type_info) & GC_IMMUTABLE)); \
ZEND_ASSERT((zval_gc_flags((p)->u.type_info) & (GC_PERSISTENT|GC_PERSISTENT_LOCAL)) != GC_PERSISTENT); \
} \
} \
} while (0)
# define GC_MAKE_PERSISTENT_LOCAL(p) do { \
Expand Down

0 comments on commit 7572d9b

Please sign in to comment.