Skip to content

AOT: mb_detect_encoding() refuses runtime strings — LogicException 1-arg NestedJIT (leftover of #3075, ext/mbstring/mbstring.c) #34358

Description

@PurHur

Category

bug · AOT NestedJIT · leftover of #3075 / peer #34338 mb_scrub · Pillar Correctness

Problem

mb_detect_encoding() JIT only compile-time-folds the 1-arg literal form. A runtime haystack (chr(0xE2).chr(0x82).chr(0xAC)) or any encodings-list argument throws:

mb_detect_encoding() JIT requires a compile-time string literal (1-arg) in this compiler build

VM/Zend return UTF-8 / ASCII. Same leftover shape as #34338 / #34309 (NestedJIT helper, no VmMbstring from thin AOT).

Verified on master @ b3cbdaf036 (aot-smoke 8/8):

Repro Zend 8.2 / VM AOT thin
$s=chr(0xE2).chr(0x82).chr(0xAC); echo mb_detect_encoding($s); UTF-8 LogicException (compile rc=2)
echo mb_detect_encoding('café', ['UTF-8','ASCII'], true); UTF-8 same LogicException
echo mb_detect_encoding('hello'); (literal) ASCII ASCII (fold)

php-src reference

PHP implementation target

  • ext/mbstring/JitMbDetectEncoding.php — NestedJIT for runtime $string; encodings list + $strict remain compile-time (peer JitMbScrub)
  • ext/mbstring/MbDetectEncodingJitHelper.php — ASCII / UTF-8 / ISO-8859-1 / 8BIT leaf; no VmMbstring / MbstringState (NestedJIT abort)
  • lib/JIT/Builtin/MbDetectEncodingRuntime.php — lazy JitVmHelperLink (not Type::initialize)

Repro

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php test/repro/aot_mb_detect_encoding_runtime.php
php bin/compile.php -o /tmp/det.bin test/repro/aot_mb_detect_encoding_runtime.php && /tmp/det.bin'

Done when

  • AOT matches Zend/VM for runtime 1-arg and literal encodings-list (+ strict)
  • Unit + repro green; ./script/aot-smoke.sh still 8/8
  • php-src-strict; no php-compiler-strict shortcut; no new runtime/*.c

Related

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-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions