Skip to content

REGRESSION: AOT ++/-- no longer applies — $n-- is a no-op, for-loop counters produce wrong results, one case hangs #23840

Description

@PurHur

Severity

On master 1608e74f9, ++ and -- do not take effect in AOT binaries. This affects the most
basic loop in PHP and produces silent wrong output. One case spins forever.

VM is unaffected. This is a regression: build/micro/m_loop.php
(for ($i = 0; $i < 1000000; ++$i) { ++$a; }) printed 1000000 correctly earlier today.

Reproducers

All built with php bin/compile.php -o <bin> <file> in php-compiler:22.04-dev, LLVM 9. No
resources open in most of them — this is not resource-related.

program Zend AOT
$n = 0; $n--; echo $n; -1 0
$n = 5; $n--; echo $n; 4 5
$n = 0; --$n; echo $n; -1 0
$n = 0; $n--; $n--; echo $n; -2 0
$n = 1; $n--; $n--; echo $n; -1 1
$acc=0; for ($i=0;$i<5;++$i) { ++$acc; } echo $acc; 5 0

The decrement is a complete no-op — the variable keeps its initial value. The loop case
produces 0, so either the body never executes or ++$acc does not apply.

One case hangs

test/differential/cases/g07_incdec_resource_provenance.php compiled and then spun at 99% CPU
for 27 minutes
before I killed it. It terminated normally in runs earlier today, producing wrong
but finite output. Anything running the AOT sweep should be aware that a case can now hang rather
than fail — my sweep script had timeout on the compile but not on the run, which is how this went
unnoticed for half an hour.

Attribution

Bisect in progress; I am not attributing this to any commit yet. Candidate range is
544d1dca9..1608e74f9, which includes:

I will post the bisect result and, if it is mine, revert it immediately.

Suggested guard once fixed

There is currently no differential case covering plain --. g07 covers ++/-- but is
marked @differential-skip-aot pending #23811, so it does not gate the AOT path. A trivial
$n = 5; $n--; case would have caught this.

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions