Skip to content

Regression: SplDoublyLinkedList::offsetSet(null, $v) overwrites index 0 — Zend appends (ext/spl/spl_dllist.c) #31731

Description

@PurHur

Category

Regression: · php-src-strict · SPL ArrayAccess null index = append

Problem

SplDoublyLinkedList::offsetSet(null, $value) (and $dll[] = $value / $dll[null] = $value) must append a new element (Zend). VM treats null as integer index 0 and overwrites the head — wrong length and wrong contents. Zend does not emit E_DEPRECATED for this null (append is intentional).

Related soft-null TypeErrors on offsetGet/offsetUnset/offsetExists/add(null) are siblings but distinct from this append rule.

Probed 2026-08-17 — host Zend PHP 8.2+ vs php bin/vm.php.

Repro Zend 8.2+ VM (2026-08-17)
push a,b then offsetSet(null, 'NEW') [0]=a [1]=b [2]=NEW count=3 [0]=NEW [1]=b count=2

php-src reference

PHP implementation target

  • ext/spl/ SplDoublyLinkedList::offsetSet — when $index === null, append (same as push); do not coerce null→0; PHP-in-PHP in ext/spl/, not new C runtime

Repro

./script/docker-exec.sh -- bash -lc 'php test/repro/maintainer_gap_dllist_offsetset_null_append.php'
./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_dllist_offsetset_null_append.php'

Done when

  • offsetSet(null, …) appends on VM (count+1, value at end); dim-write $dll[] / $dll[null] agree
  • Compliance .phpt guard under test/compliance/cases/
  • php-src-strict; no php-compiler-strict shortcut

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machinebugSomething isn't workingimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions