Skip to content

AOT: mb_strwidth()/mb_strimwidth() refuse runtime encoding — LogicException (leftover of #34264, ext/mbstring/mbstring.c) #34884

Description

@PurHur

Category

bug · AOT · stdlib · mbstring · NestedJIT · php-src-strict

Problem

After #34858 / #34875 / #34880 wave, mb_strwidth() / mb_strimwidth() still refuse a runtime encoding string (JitMbStrwidth throws LogicException: … encoding must be a string literal). Invalid encoding literals also abort compile via VmMbstring::strwidth fold instead of a catchable runtime ValueError.

Repro Zend 8.2+ AOT (master @ 8a29eaf)
mb_strwidth('über', enc()) with enc()=>'UTF-8' int(4) compile: LogicException encoding must be a string literal
mb_strimwidth('übercafé', 0, 5, '...', enc()) üb... same LogicException
$e='NOPE'; try { mb_strwidth('x',$e); } catch (ValueError) catchable ValueError compile-time uncaught ValueError

./script/aot-smoke.sh is 8/8. Peer closed: #34858, #34875, #34880.

php-src reference

PHP implementation target

Repro

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
export PHP_COMPILER_HELPER_RUNTIME_O=0
php bin/compile.php -o /tmp/t.bin test/repro/mb_strwidth_runtime_encoding_aot.php && /tmp/t.bin
php test/repro/mb_strwidth_runtime_encoding_aot.php
'

Done when

  • AOT matches Zend for runtime UTF-8 encoding on strwidth/strimwidth
  • Invalid encoding is catchable ValueError at runtime (not compile abort)
  • Targeted phpunit green; ./script/aot-smoke.sh stays 8/8
  • No new runtime/*.c

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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