Skip to content

Regression: AOT DateTime::diff() segfaults after build — VM/JIT match Zend (ext/date/php_date.c) #27309

Closed

Description

@PurHur

Category

bug · php-src-strict · AOT / ext/date

Problem

$a->diff($b)->days for 2024-01-01 → 2024-01-10 prints 9 on Zend, VM, and JIT. Thin AOT builds successfully, then the binary segfaults (exit 139) with phpc: fatal signal (segfault) after c:main_before_php.

Closed #26693 covered fractional $f on VM; this is AOT crash with VM/JIT green.

Repro Zend / VM / JIT (2026-08-03) AOT
DateTime('2024-01-01')->diff(DateTime('2024-01-10'))->days 9 segfault after c:main_before_php

Verified on master f20c74a10.

php-src reference

PHP implementation target

  • Fix AOT lowering for DateTime::diff() / date_diff() → DateInterval in ext/date/ + lib/JIT/ (PHP-in-PHP)
  • No new C in runtime/

Repro

./script/docker-exec.sh -- bash -lc '
cat >/tmp/dt_diff.php <<'"'"'P'"'"'
<?php
$a = new DateTime("2024-01-01");
$b = new DateTime("2024-01-10");
echo $a->diff($b)->days, PHP_EOL;
P
php /tmp/dt_diff.php
php bin/vm.php /tmp/dt_diff.php
php bin/jit.php /tmp/dt_diff.php
./phpc build -o /tmp/dt_diff.bin /tmp/dt_diff.php && /tmp/dt_diff.bin
'

Done when

  • AOT prints 9 matching Zend/VM/JIT (no segfault; re-run binary ≥3×)
  • Compliance or AOT fixture guard; php-src-strict

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 3, 2026
  2. PurHur commented on Aug 3, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib Advanced — batch (issues #27307, #27308, #27309, #27262)

    ext/date AOT regressions: DateTimeZone::getName/getOffset, DateTime::diff, DateTimeImmutable::modify(+1 month). Sequential PRs; starting with #27307.

  3. PurHur commented on Aug 3, 2026

    @PurHur
    OwnerAuthor

    Merged in #27339

    Verification (docker-exec):

    • AOT DateTime('2024-01-01')->diff(DateTime('2024-01-10'))->days → 9 (×3)
    • vendor/bin/phpunit --filter datetime_diff_days test/aot/AotTest.php → OK
    • new DateInterval('P9D') still builds; inventory/spine OK

    Batch status: #27307, #27308, #27309 merged. Next: #27262 DateTimeImmutable::modify(+1 month).

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