Repository navigation
🐛 fix(js): raise MemoryError for lost fold caches - #2544
Merged
Merged
Conversation
Two allocations added for speed fell back quietly when they failed: the analysis the compress pass hands to the mangler (tox-dev#2485) and the fold's per-function walk marks. minify_js() then returned its output instead of raising MemoryError, as every other allocation failure in the JavaScript minifier does, and the allocation-failure sweep in test_self_test.py caught it. Both now mark the program failed.
Three fuzz-build self-tests stopped testing anything once faster code paths landed: - detect() settles a byte order mark without ranking (tox-dev#2471), so the BOM input made no allocation for the sweep to fail. - Text.text of a lone Text node builds its str in place (tox-dev#2508), which makes no PyMem allocation the hook can fail; only .data still does. - tox-dev#2398 reuses a context-free inner count(), so the nested expression no longer reached the operation limit. The detect sweep now feeds input the ranking has to weigh, the text sweep keeps .data, and the operation-limit expression nests counts that depend on their context node.
Merging this PR will not alter performance
Comparing Footnotes
|
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.
The fuzz-build self-tests in
tests/_html/fuzz/test_self_test.py(-m fuzz_build, run bytox -e fuzz-smoke) have 11 failures on main. They went unnoticed because the scheduled fuzz workflow has stopped at its sanitizer self-check (_fuzz_crash(...)exits without the expected AddressSanitizer report) since 2026-11-16, before pytest starts. The last run that reached these tests, on 2026-11-14 at 552f9af, passed all 150. A local build with the same flags minus the sanitizers (debugoptimized,-Dfuzzing=true,-DTH_OPERATION_LIMIT=100000,PYTHONHASHSEED=0) matches that result at 552f9af and shows the 11 failures on main. Bisecting with it gave these causes:minify_jsallocation sweepsjm_compress()hands to the mangler (#2485) and the fold's per-function walk marks (mark_walked()).minify_js()returned its output instead of raisingMemoryError, as every other failed allocation in the minifier does.b43a59379).test_detect_allocation_failure_raises_memory_errordetect(b"\xef\xbb\xbftext")makes no allocation for the sweep to fail.b"caf\xe9 text", which the ranking has to weigh.test_text_access_allocation_failure_raises_memory_error[text].textwithPyUnicode_New. That allocates from the object domain, which the PyMem hook does not cover, so there is nothing to fail. The NULL check is in place..datasweep.test_operation_limit_stops[xpath]count(//a), so the nested expression finishes far below the limit.count(//a[count(../a[count(../a) > 0]) > 0]).With these changes all 164
fuzz_buildtests pass on that build, andtox -e 3.15passes overtests/jsandtests/query/xpath. This PR doesn't fix the sanitizer self-check failure in the scheduled workflow.