Repository navigation
fix(engine): bound the depth of the expanded object display - #5665
Open
adisingh396 wants to merge 1 commit into
Open
adisingh396 wants to merge 1 commit into
adisingh396 wants to merge 1 commit into
Conversation
console.dir (and %o) reached log_object_to_internal, which carried only a cycle-detection set and no depth argument. An acyclic chain of plain objects therefore recursed without bound: the indent grows 4 per level and every line re-emits it, so output is O(depth^2) (1200 levels asked for over 12 GB and was OOM-killed), and past depth 16383 the indent overflows the u16 width accepted by core::fmt and to_string panics. Thread a depth counter through log_object_to_internal and both of its recursion edges, and collapse at EXPANDED_DEPTH_LIMIT (32), the same way the compact printer already collapses at COMPACT_DEPTH_LIMIT. Test: a 1000-deep object chain through display_obj(true) renders [Object] at the cut instead of exhausting the stack or panicking. Closes boa-dev#5654
HalidOdat
reviewed
Nov 14, 2026
Comment on lines
35
to
+36
| indent: usize, | ||
| depth: u32, |
Member
There was a problem hiding this comment.
passing indent and depth seems redundant to me, since you can derive indent from depth i.e, indent = depth * INDENT_SIZE, where INDENT_SIZE is 4.
This branch has not been deployed
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.
Summary
console.dir(and%o) reacheslog_object_to_internal, which carried only a cycle-detection set and no depth argument. An acyclic chain of plain objects recursed without bound:u16width accepted bycore::fmtandto_string()panics.This threads a depth counter through
log_object_to_internaland its two recursion edges, and collapses atEXPANDED_DEPTH_LIMIT(32) the same way the compact printer already collapses atCOMPACT_DEPTH_LIMIT.Closes #5654
Tests
New unit test
display_obj_bounds_nesting_depthbuilds a 1000-deep object chain and assertsdisplay_obj(true)renders[Object]at the cut instead of exhausting memory/stack or panicking.cargo fmt --all -- --check→ cleancargo clippy -p boa_engine --all-targets -- -D warnings→ cleancargo test -p boa_engine --lib→test result: ok. 1125 passed; 0 failed(1124 before, +1 new)Not run here:
cargo test --workspace(Windows host, this change is engine-local) and the Test262 suite.