Skip to content

Regression: AOT DOMDocument::saveXML(int) in try{} compile-fails via SimpleXMLElement::asXML (re-#31396, RuntimeIndirect) #34567

Description

@PurHur

Category

Regression · AOT · DOM · re-#31396 / peer RuntimeIndirect vs SimpleXML FALIAS

Problem

DOMDocument::saveXML(1) / saveHTML(1) / saveXML('x') inside try fail at AOT compile with:

SimpleXMLElement::asXML() user-script AOT requires a compile-time constructed tree (#19306)

Zend and VM catch TypeError as expected. Without try, thin AOT compiles and raises the TypeError at runtime. Inside try, the receiver operand loses TYPE_OBJECT, so RuntimeIndirectInstanceMethodCall builds candidates for every class that defines saveXML — including SimpleXMLElement's FALIAS of asXML. Emitting the SXE arm throws at compile time even though the runtime class_id would select DOMDocument.

Repro Zend / VM AOT (master @ 8c55585)
try { $d->saveXML(1); } catch … TypeError caught compile exit 2 (SXE asXML)
bare $d->saveXML(1); TypeError fatal TypeError fatal (OK)

php-src reference

PHP implementation target

  • lib/JIT.php — early-bind domdocument::savexml / savehtml before RuntimeIndirect when Dom kernel is active (peer appendChild / c14n)
  • lib/JIT/Call/RuntimeIndirectInstanceMethodCall.php — do not let one candidate's compile-time LogicException abort the whole module

Repro

./script/aot-smoke.sh
./script/docker-exec.sh -- bash -lc 'php test/repro/aot_dom_savexml_int_typeerror.php'
./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/aot_dom_savexml_int_typeerror.php'
./script/docker-exec.sh -- bash -lc 'PHP_COMPILER_HELPER_RUNTIME_O=0 php bin/compile.php -o /tmp/t test/repro/aot_dom_savexml_int_typeerror.php && /tmp/t'
./script/phpunit.sh --filter DomSaveXmlIntTypeErrorAotTest

Done when

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

    area:compilerCompiler / CFG / JITbugSomething isn't workingimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language features

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions