Skip to content

AOT: mb_strtolower()/mb_strtoupper()/mb_ucfirst()/mb_lcfirst() refuse runtime encoding — LogicException (leftover of #34625, ext/mbstring/mbstring.c) #34858

Description

@PurHur

Category

bug · AOT · mbstring · leftover of #34625 / peer #4405

Problem

mb_strlen($s, $encoding) with a runtime encoding variable works under AOT after #34625, but mb_strtolower / mb_strtoupper / mb_ucfirst / mb_lcfirst still fail at compile time:

mb case JIT encoding must be a string literal in this compiler build

VM matches Zend. Literal encoding already works via NestedJIT MbCaseJitHelper.

Repro Zend 8.2+ AOT (master @ 74e8a5e)
$e='UTF-8'; echo mb_strtolower('Ä', $e); ä LogicException at compile
$e='UTF-8'; echo mb_strtoupper('ä', $e); Ä same
$e='UTF-8'; echo mb_ucfirst('äx', $e); Äx same (mb_ucfirst()/mb_lcfirst() encoding must be a string literal…)

Root cause: JitMbCase::runtimeEncodingLiteral / JitMbUcfirstLcfirst::runtimeEncodingLiteral require TYPE_STRING + compileTimeString. Runtime locals are TYPE_VALUE.

./script/aot-smoke.sh is 8/8.

php-src reference

PHP implementation target

Repro

./script/docker-exec.sh -- bash -lc 'php bin/compile.php -o /tmp/x test/repro/stdlib-aot/mb_strtolower_enc.php'

Done when

  • AOT matches Zend for runtime encoding on mb_strtolower/toupper/ucfirst/lcfirst
  • Invalid runtime encoding → catchable ValueError (not LogicException at compile)
  • ./script/aot-smoke.sh stays 8/8
  • Targeted phpunit + aot-smoke green

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 apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions