Skip to content

Investigate an assertion error in zend_string_destroy #6

Closed

Description

@lisachenko

Test suite fails in PHP 7.4.0RC3 debug build with message:

php-src/Zend/zend_variables.c:64: zend_string_destroy: Assertion `!(zval_gc_flags((str)->gc.u.type_info) & (1<<6))' failed.

Need to fix this assertion error.

Activity

  1. lisachenko commented on Oct 1, 2019

    @lisachenko
    OwnerAuthor

    I don't know ways to debug this issue, it's too complex right now.

    I have a guess, that I'm using immutable strings from PHP. For example, immutable method names in tests and steal pointer to them to use in misc areas of code instead of crafting zend_string entry by hand. Probably, at the end of request GC tries to clean something (hashtable?) and assertion fails.

  2. lisachenko commented on Aug 9, 2026

    @lisachenko
    OwnerAuthor

    Should be fixed

  3. lisachenko commented on Aug 9, 2026

    @lisachenko
    OwnerAuthor

    Verified independently against the current codebase — confirming this stays closed.

    Fix confirmed present and effective on both supported branches:

    • ReferenceCountedTrait::incrementReferenceCount()/decrementReferenceCount() now throw on immutable payloads (interned strings, immutable arrays, shared-memory data) instead of mutating them.
    • releaseReference() no-ops entirely for immutable/interned payloads, and only invokes the engine's own rc_dtor_func at refcount zero for non-persistent, non-immutable payloads — mirroring zend_string_release_ex's GC_IMMUTABLE guard that the original assertion was tripping.
    • StringEntry's constructor skips add-ref for interned strings up front (second independent guard layer).
    • Landed in 8e017a2 (fix(core): guard refcount mutation against immutable payloads and underflow) on branch 8.4, and already cascaded to master (PHP 8.5) via the automated merge-up (PR merge: cascade 8.4 into master (windows x64, resolved) #182, commit 2c70d43) — 8e017a2 is confirmed an ancestor of origin/master.

    Verified on both PHP 8.4 and 8.5:

    • Branch 8.4 (PHP 8.4) and master (PHP 8.5) both carry the fix.
    • Both branches' tests-internal-debug CI job (a --enable-debug PHP build built specifically to surface Zend assertion failures like this one) is green on their current HEAD — 8.4@8419047 and master@4195cef.
    • StringEntryOwnershipTest exercises interned-string release semantics directly.

    No further code changes needed — closing confirmed as correct.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't working

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions