Skip to content

AOT: mb_trim/mb_ltrim/mb_rtrim refuse runtime strings — LogicException (leftover of #5957/#23883, ext/mbstring/mbstring.c) #34379

Description

@PurHur

Category

bug · AOT · mbstring · leftover of #5957 / #23883

Problem

mb_trim() / mb_ltrim() / mb_rtrim() fold compile-time string literals, then throw at JIT/AOT compile for runtime haystacks:

LogicException: mb_trim() is not lowered for JIT/AOT in this compiler build

Same leftover shape as #34338 (mb_scrub) / #34358 (mb_detect_encoding): NestedJIT runtime path missing.

Repro Zend 8.4+ AOT (master)
$s = " hi "; echo mb_trim($s); hi LogicException at compile

php-src reference

PHP implementation target

  • ext/mbstring/JitMbTrim.php — NestedJIT runtime via helper (peer JitMbScrub)
  • ext/mbstring/MbTrimJitHelper.php + lib/JIT/Builtin/MbTrimRuntime.php
  • Encoding / $characters stay compile-time literals (NestedJIT array/state constraints)

Repro

./script/docker-exec.sh -- bash -lc 'printf "%s\n" "<?php \$s=\"  hi  \"; echo mb_trim(\$s), PHP_EOL;" > /tmp/t.php; php bin/compile.php -o /tmp/t.bin /tmp/t.php'

Done when

  • AOT binary for runtime haystack matches Zend stdout for default UTF-8 trim / ltrim / rtrim
  • No new runtime/*.c; NestedJIT PHP helper only
  • Targeted unit/AOT test 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 appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions