Skip to content

Regression: addcslashes() arity error throws LogicException — Zend ArgumentCountError (ext/standard/string.c) #21756

Closed

Description

@PurHur

Category

Regression · php-src-strict · wrong exception class (peer #21736)

Problem

Calling addcslashes() with one argument throws LogicException on the VM; Zend throws ArgumentCountError with the standard arity message.

Repro Zend 8.2+ VM (2026-07-21)
addcslashes(null) ArgumentCountError: addcslashes() expects exactly 2 arguments LogicException: addcslashes() requires exactly two arguments

php-src reference

PHP implementation target

  • ext/standard/addcslashes.php (or shared string builtin base) — throw ArgumentCountError for wrong arity; reuse shared guard if one exists for other string builtins
  • JIT lowering: same exception type when compiled

Repro

./script/docker-exec.sh -- bash -lc 'php -r "try { addcslashes(null); } catch (Throwable \$e) { echo get_class(\$e); }"; php bin/vm.php -r "try { addcslashes(null); } catch (Throwable \$e) { echo get_class(\$e); }"'

Done when

  • VM/JIT: wrong arity → ArgumentCountError matching Zend message shape
  • Compliance guard under test/compliance/cases/string/
  • php-src-strict

Activity

  1. added
    bugSomething isn't working
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jul 21, 2026
  2. PurHur commented on Jul 21, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib — starting this run

  3. PurHur commented on Jul 21, 2026

    @PurHur
    OwnerAuthor

    Merged via #21772

    Fix: addcslashes() VM/JIT arity now uses Internal::requireExactArgCount / requireExactJitArgCount (Zend ArgumentCountError message shape).

    Verification:

    • php bin/vm.php -r '…' → ArgumentCountError: addcslashes() expects exactly 2 arguments, 1 given
    • ./script/phpunit.sh --filter addcslashes_argument_count → OK (4 tests)
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