Skip to content

Regression: AOT cos() returns 0 — VM/JIT match Zend (ext/standard/math.c) #27005

Description

@PurHur

Category

bug · php-src-strict · AOT · pillar 4

Problem

cos() matches Zend on VM and JIT, but the AOT-built binary prints 0 (silent wrong output). cosh(0) shows the same zeroed return under AOT.

Repro Zend / VM / JIT (2026-08-02, d9449a349) AOT after bin/compile.php
echo cos(0) 1 0 (exit 0)
echo cosh(0) 1 0 (exit 0)

php-src reference

PHP implementation target

  • ext/standard/cos.php / ext/standard/cosh.php + AOT/JIT float-math lowering — PHP-in-PHP
  • Confirm shared float boxing with other AOT math helpers that return 0

Repro

./script/docker-exec.sh -- bash -lc '
cat > /tmp/aot_cos.php <<'"'"'PHP'"'"'
<?php
echo cos(0), "\n";
echo cosh(0), "\n";
PHP
echo -n "zend="; php /tmp/aot_cos.php
echo -n "vm="; php bin/vm.php /tmp/aot_cos.php 2>/dev/null
echo -n "jit="; php bin/jit.php /tmp/aot_cos.php 2>/dev/null | grep -v Deprecated
php bin/compile.php -o /tmp/aot_cos /tmp/aot_cos.php && /tmp/aot_cos
'

Done when

  • AOT binary prints 1 / 1 matching Zend/VM/JIT
  • Prefer --repeat 10 on the built binary before claiming fixed
  • Compliance or test/repro/ guard
  • php-src-strict; no php-compiler-strict shortcut

Activity

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

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib — starting this run

    Pillar gates (pre-claim):

  3. PurHur commented on Aug 2, 2026

    @PurHur
    OwnerAuthor

    Merged in #27061

    Fix: CosJitHelper/CoshJitHelper no longer call VmMath under NestedJIT (null→0). libc leaf kernels phpc_cos_kernel / phpc_cosh_kernel + MathCos/MathCosh NestedJitCompileScope short-circuit (ceil/sqrt peer).

    Verified:

    • AOT test/repro/issue_27005_aot_cos_cosh.php → 1\n1 (repeat 10/10)
    • VM + JIT match Zend
    • inventory --check OK; spine sync OK; Cos/Hyperbolic shrink unit tests OK
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:compilerCompiler / CFG / JITbugSomething 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