Category
bug · AOT · stdlib · mbstring · php-src-strict
Problem
mb_substr() / mb_strcut() NestedJIT already accepts runtime string/offsets (#34256) but still requires a compile-time encoding literal. A runtime encoding (e.g. $argv[1] or non-folded concat) aborts compile with LogicException instead of matching Zend/VM. Invalid encoding names throw LogicException at compile time instead of catchable ValueError.
| Repro |
Zend 8.2+ |
VM |
AOT (master) |
mb_substr("あいう", 1, 1, $argv[1]) with UTF-8 |
い |
い |
LogicException at compile |
mb_substr("abc", 0, 1, "NOPE") in try/catch |
ValueError |
ValueError |
LogicException at compile |
Peer closed: #34870 (mb_chr/ord), #34866 (mb_strpos family), #34858 (mb_strtolower/toupper), #34625 (mb_strlen). ./script/aot-smoke.sh is 8/8.
php-src reference
PHP implementation target
ext/mbstring/mb_substr.php (JitMbSubstr) / ext/mbstring/JitMbStrcut.php — encodingPtr + NestedJIT assertEncodingArgv (peer JitMbSearch / JitMbCase)
ext/mbstring/MbStrcutJitHelper.php + lib/JIT/Builtin/MbStrcut.php — compile assert helper; no new runtime/*.c
Repro
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
TMP=$(mktemp -d)
cat >"$TMP/t.php" <<PHP
<?php
\$e = \$argc > 1 ? \$argv[1] : ("UTF-"."8");
echo mb_substr("あいう", 1, 1, \$e), "\\n";
PHP
php bin/vm.php "$TMP/t.php" UTF-8
php bin/compile.php -o "$TMP/t.bin" "$TMP/t.php"
'
Done when
Category
bug· AOT · stdlib · mbstring · php-src-strictProblem
mb_substr()/mb_strcut()NestedJIT already accepts runtime string/offsets (#34256) but still requires a compile-time encoding literal. A runtime encoding (e.g.$argv[1]or non-folded concat) aborts compile withLogicExceptioninstead of matching Zend/VM. Invalid encoding names throwLogicExceptionat compile time instead of catchableValueError.mb_substr("あいう", 1, 1, $argv[1])withUTF-8いいmb_substr("abc", 0, 1, "NOPE")in try/catchPeer closed: #34870 (mb_chr/ord), #34866 (mb_strpos family), #34858 (mb_strtolower/toupper), #34625 (mb_strlen).
./script/aot-smoke.shis 8/8.php-src reference
ext/mbstring/mbstring.c—PHP_FUNCTION(mb_substr)/PHP_FUNCTION(mb_strcut)ValueErroron invalid namesPHP implementation target
ext/mbstring/mb_substr.php(JitMbSubstr) /ext/mbstring/JitMbStrcut.php—encodingPtr+ NestedJITassertEncodingArgv(peerJitMbSearch/JitMbCase)ext/mbstring/MbStrcutJitHelper.php+lib/JIT/Builtin/MbStrcut.php— compile assert helper; no newruntime/*.cRepro
Done when
mb_substr/mb_strcutValueError(Argument Stdlib: round, sqrt, gettype and expanded PHPT specs #4), not compile-time LogicException./script/aot-smoke.shstays 8/8runtime/*.c