Category
language · runtime · stdlib bridge
Problem
User try/catch blocks must intercept exceptions thrown from internal/builtin handlers the same way Zend does. Today:
ValueError from builtins can be swallowed — substr_compare(..., -1) inside catch (ValueError) prints no throw and exits 0 on VM, while Zend catches.
LogicException/TypeError from builtins ignore catch blocks — floor($object) inside catch (TypeError) either fatals through the handler (LogicException path) or silently continues (no throw), never entering the user catch.
Bare throw new ValueError(...) is catchable (probe14e green), so the bug is specific to exceptions raised from Internal::execute() / VM dispatch, not the catch machinery itself.
Related umbrella: #4178 (wrong exception type from builtins) — fix types and ensure they propagate into active catch frames.
php-src reference
Repro
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro-maintainer/parity_builtin_try_catch.php; echo zend:$?
php bin/vm.php test/repro-maintainer/parity_builtin_try_catch.php; echo vm:$?
'
| Case |
Zend |
VM |
substr_compare negative length in catch (ValueError) |
caught ValueError |
no throw |
floor(object) in catch (TypeError) |
caught TypeError |
no throw |
Repro script: test/repro-maintainer/parity_builtin_try_catch.php
Scope (this repo)
| Area |
Files |
| VM |
lib/VM.php — internal handler exception dispatch into catch stack |
| VM |
lib/VM/ExceptionSupport.php — ValueError/TypeError bridging |
| Stdlib |
ext/standard/*.php — after VM fix, migrate LogicException → TypeError/ValueError (#4178) |
| Tests |
test/compliance/cases/language/builtin_try_catch.phpt |
Done when
Links
Category
language·runtime·stdlib bridgeProblem
User
try/catchblocks must intercept exceptions thrown from internal/builtin handlers the same way Zend does. Today:ValueErrorfrom builtins can be swallowed —substr_compare(..., -1)insidecatch (ValueError)printsno throwand exits 0 on VM, while Zend catches.LogicException/TypeErrorfrom builtins ignore catch blocks —floor($object)insidecatch (TypeError)either fatals through the handler (LogicException path) or silently continues (no throw), never entering the user catch.Bare
throw new ValueError(...)is catchable (probe14egreen), so the bug is specific to exceptions raised fromInternal::execute()/ VM dispatch, not the catch machinery itself.Related umbrella: #4178 (wrong exception type from builtins) — fix types and ensure they propagate into active catch frames.
php-src reference
Zend/zend_exceptions.c—zend_throw_exception_internal, activetry_catch_arrayZend/zend_execute.c—ZEND_HANDLE_EXCEPTIONRepro
substr_comparenegative length incatch (ValueError)caught ValueErrorno throwfloor(object)incatch (TypeError)caught TypeErrorno throwRepro script:
test/repro-maintainer/parity_builtin_try_catch.phpScope (this repo)
lib/VM.php— internal handler exception dispatch into catch stacklib/VM/ExceptionSupport.php— ValueError/TypeError bridgingext/standard/*.php— after VM fix, migrate LogicException → TypeError/ValueError (#4178)test/compliance/cases/language/builtin_try_catch.phptDone when
caught ValueError+caught TypeErroron VM (exit 0)./script/ci-fast.sh --filter builtin_try_catchgreenLinks