Skip to content

Stdlib: assert() failure warns E_USER_WARNING "Assertion failed" — Zend E_WARNING "assert(): … failed" (ext/standard/assert.c) #23731

Closed

Description

@PurHur

Category

Stdlib · php-src-strict · assert · pillar 4

Problem

With assertions active and assert.exception=0, a failing assert() on this VM emits E_USER_WARNING (512) with message Assertion failed: x. Zend emits E_WARNING (2) with assert(): x failed.

Verified 2026-07-27 against php:8.4-cli 8.4.23 (zend.assertions=1 at runtime). Pinned image Zend 8.2 cannot flip zend.assertions via ini_set (php.ini-only) — use 8.4 reference for this slice.

Repro Zend 8.4 VM
assert(false, "x") with exception off W:2:assert(): x failed W:512:Assertion failed: x

(assert.exception=1 → AssertionError already matches Zend.)

php-src reference

PHP implementation target

  • ext/standard/ assert implementation (PHP-in-PHP) — emit E_WARNING and message assert(): {description} failed (or Zend's exact format for the description form used)
  • Mirror JIT/AOT assert helpers; no new C assert paths in runtime/

Repro

# Zend 8.4 reference (pinned CI Zend 8.2 cannot enable zend.assertions at runtime):
docker run --rm -i \$HARNESS_DOCKER_RUN_OPTS --entrypoint php php:8.4-cli /dev/stdin <<'PHP'
<?php
ini_set("zend.assertions", "1");
ini_set("assert.exception", "0");
error_reporting(E_ALL);
function handler($no, $str) { echo "W:$no:$str\n"; return true; }
set_error_handler("handler");
assert(false, "x");
echo "after\n";
PHP

./script/docker-exec.sh -- bash -lc 'cat > /tmp/assert_w.php <<'"'"'PHP'"'"'
<?php
ini_set("zend.assertions", "1");
ini_set("assert.exception", "0");
error_reporting(E_ALL);
function handler($no, $str) { echo "W:$no:$str\n"; return true; }
set_error_handler("handler");
assert(false, "x");
echo "after\n";
PHP
php bin/vm.php /tmp/assert_w.php'

Done when

  • Failing assert (exception off) reports level 2 (E_WARNING) and Zend message shape assert(): … failed
  • assert.exception=1 still throws AssertionError (unchanged)
  • Compliance .phpt under test/compliance/cases/
  • php-src-strict; no php-compiler-strict shortcut

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 27, 2026
  2. PurHur commented on Jul 27, 2026

    @PurHur
    OwnerAuthor

    Merged in #23767.

    Verification: php bin/vm.php -r 'ini_set("zend.assertions","1"); ini_set("assert.exception","0"); ... assert(false,"x");' → W:2:assert(): x failed. PHPUnit filter assert_warning_parity green (VM+JIT).

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