Skip to content

AOT: fix mb_trim NestedJIT rtrim wrong output (leftover #34396) - #34532

Merged
PurHur merged 1 commit into
masterfrom
agent/ext-io-34379-mb-trim-substr-aot
Aug 24, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/ext-io-34379-mb-trim-substr-aot

Conversation

@PurHur

@PurHur PurHur commented Aug 24, 2026

Copy link
Copy Markdown
Owner

Summary

Repro (before)

./script/docker-exec.sh -- bash -lc 'export PHP_COMPILER_PROFILE=8.4 PHP_COMPILER_HELPER_RUNTIME_O=0; php bin/compile.php -o /tmp/t.bin test/repro/aot_mb_trim_runtime.php && /tmp/t.bin'
# AOT: h / hi\t / (space) / x … vs VM/Zend: hi / hi\t / ␠␠hi / x …

Verification

./script/aot-smoke.sh
# aot-smoke: 8 passed, 0 failed

./script/phpunit.sh --filter MbTrimRuntimeAotTest
# OK (2 tests, 14 assertions)

./script/docker-exec.sh -- bash -lc 'export PHP_COMPILER_PROFILE=8.4 PHP_COMPILER_HELPER_RUNTIME_O=0; php bin/vm.php test/repro/aot_mb_trim_runtime.php; php bin/compile.php -o /tmp/t.bin test/repro/aot_mb_trim_runtime.php && /tmp/t.bin'
# VM and AOT output identical (6 lines each)

php-src reference

  • ext/mbstring/mbstring.c — PHP_FUNCTION(mb_trim) / default charset table

Closes #34379

Made with Cursor

MbTrimJitHelper used substr() and index-subtraction patterns that thin AOT
miscompiles; rewrite rtrim with byte indexing, copyPrefix, and C2-hold NBSP
deferral so runtime haystack trim matches VM/Zend.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit 261241f into master Aug 24, 2026
1 check failed
@PurHur
PurHur deleted the agent/ext-io-34379-mb-trim-substr-aot branch August 24, 2026 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant