Skip to content

Language: include() of syntax-error file is process fatal — Zend catchable ParseError (Zend/zend_execute.c) #32154

Description

@PurHur

Category

language · php-src-strict · include · ParseError

Problem

include of a file with a syntax error is a catchable ParseError in php-src: user try/catch (Throwable) runs and execution continues. This compiler aborts the process with parseAndCompile failure, leaks PhpParser\Error / bundle_snippet internals, and never enters the catch block.

Repro Zend 8.2+ VM/JIT (2026-08-18 @ 8d228396dc)
try { include 'bad.php'; echo "after"; } catch (Throwable $e) { echo get_class($e), ':', $e->getMessage(); } where bad.php is <?php echo 1 2; stdout ParseError:syntax error, unexpected integer "2", expecting "," or ";" (rc=0) process fatal parseAndCompile failure + PhpParser dump (rc=255); catch never runs

Silent-wrong vs Zend: callers cannot recover from a bad include the way php-src allows.

php-src reference

PHP implementation target

  • lib/ include/require compile-and-run — convert php-parser syntax errors into a catchable ParseError (Zend message text) instead of aborting parseAndCompile
  • Do not leak PhpParser\Error or bundle_snippet to user stderr
  • JIT/AOT must match VM; no new runtime/*.c logic

Repro

./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_include_parse.php 2>&1 | head -8'
./script/docker-exec.sh -- bash -lc 'php bin/jit.php test/repro/maintainer_gap_include_parse.php 2>&1 | head -8'

Done when

  • try { include …syntax error… } catch (Throwable $e) on VM and JIT prints ParseError: plus Zend substring unexpected / integer 2 (or equivalent php-src 8.2 token text) and rc=0
  • No parseAndCompile failure / PhpParser\ / bundle_snippet on stderr
  • Compliance .phpt guard under test/compliance/cases/language/include_parse_error*.phpt
  • php-src-strict; no php-compiler-strict shortcut

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 / JITarea:vmVirtual machinebugSomething 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