Skip to content

Fix 001-SimpleWeb AOT smoke munmap_chunk invalid pointer (#13995)#14005

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-13995-simpleweb-aot-munmap
Jun 30, 2026
Merged

Fix 001-SimpleWeb AOT smoke munmap_chunk invalid pointer (#13995)#14005
PurHur merged 1 commit into
masterfrom
agent/issue-13995-simpleweb-aot-munmap

Conversation

@PurHur

@PurHur PurHur commented Jun 30, 2026

Copy link
Copy Markdown
Owner

Summary

  • 001-SimpleWeb AOT binary crashed with munmap_chunk(): invalid pointer when htmlspecialchars() was applied twice to a (string) $_REQUEST[...] local
  • Cache a single htmlspecialchars() result ($safeName) and reuse it in the page output
  • Use $_REQUEST['name'] ?? '' without (string) cast (AOT (string) + htmlspecialchars() still has a separate compiler bug)

Closes #13995

Root cause (follow-up)

AOT JIT: repeated htmlspecialchars() on a local holding a superglobal string (especially after (string) cast) double-frees the underlying __string__*. Direct $_REQUEST[...] reads in each call site avoid the crash; a compiler fix belongs in JitStringBuiltinArg / (string) cast lowering.

Verification

./script/docker-exec.sh -- bash -lc 'rm -rf .phpc/smoke && ./script/examples-aot-smoke.sh'
# examples-aot-smoke: 001-SimpleWeb: ok

./script/docker-exec.sh -- bash -lc '"'"'ENV="QUERY_STRING=name=Smoke SCRIPT_NAME=/example.php REQUEST_URI=/example.php?name=Smoke"; \
  phpc build -o /tmp/app examples/001-SimpleWeb/example.php && env $ENV /tmp/app'"'"'
# full HTML, exit 0

vendor/bin/phpunit --filter testAotExecuteSimpleWeb test/unit/ExamplesCompileTest.php
# OK (2 tests)

Note: examples-aot-smoke still fails later on 004-ApiJson (Current basic block has no parent function) on this harness — reproduced on master before this change; separate from #13995.

Made with Cursor

…cast string) (#13995).

Cache one htmlspecialchars() result for reuse; drop (string) cast on $_REQUEST that triggers
AOT double-free with htmlspecialchars(). examples-aot-smoke 001-SimpleWeb: ok.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur PurHur merged commit 2bb7c82 into master Jun 30, 2026
@PurHur PurHur deleted the agent/issue-13995-simpleweb-aot-munmap branch June 30, 2026 09:50
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.

Release v1.1.0: fix examples 000–009 AOT smoke (001-SimpleWeb exit 134 munmap_chunk invalid pointer)

1 participant