Repository navigation
Conversation
This comment was marked as spam.
This comment was marked as spam.
This was referenced Oct 23, 2026
research: ASan baseline and evidence-backed cross-version OOM comparisons
forgeblueai/php-core-lab#2
Closed
Kaus1ubh
force-pushed
the
codex/urlencode-fallible-oom
branch
from
November 23, 2026 21:13
72c0cec to
d306d11
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With a 16 MiB memory limit and a 200% hard limit, encoding a 12 MiB string of NUL bytes currently terminates the process with exit 137 before registered shutdown handlers run. Both
urlencode()andrawurlencode()reach the non-fallible allocation path when reserving the output buffer.This changes the PHP functions to use fallible allocation and return through
RETURN_OOM()on failure. The original buffer is released if truncation fails. The exported C functionsphp_url_encode()andphp_raw_url_encode()keep their existing allocation behavior and return contract; their callers in cookies, sessions, phpinfo and query building still assume a non-NULL result.This addresses the two PHP functions from #24492 and complements #24548, which leaves URL encoding out of scope. Making the C functions fallible would change their contract for every caller, so it is left out of this fix.
Validation on Linux with a debug/AddressSanitizer build of PHP-8.4:
ASAN_OPTIONS=detect_leaks=0 SKIP_ASAN=1; normal Zend allocator enabled.Rebased onto current PHP-8.4; the NEWS entry is under 8.4.29. CI covers Windows and the non-ASAN builds.