Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Stack Overflow for Debug::fmt #630

Merged
merged 4 commits into from
Aug 17, 2020
Merged

Fix Stack Overflow for Debug::fmt #630

merged 4 commits into from
Aug 17, 2020

Conversation

jcdickinson
Copy link
Contributor

This Pull Request fixes/closes #608.

It changes the following:

  • Adds RecursionLimiter. This tracks the GcObject pointers that have been visited during a Debug::fmt call.
  • Adds a test for the stack overflow.

The same object cannot appear twice in the output, by design. JS object graphs tend the be huge, and comprehending a massive data dump is nearly impossible. If the same object appears twice, even if not recursive, it is always elided. The following graph:

let a = {};
a.c = a;
let b = {
 d: a, e: a
};
debug(b);

Would print:

{
  d: {
    c: ... // Recursion protected
  },
  e: ... // Will never appear twice
}

@jcdickinson jcdickinson changed the title Stackoverflow Fix Stack Overflow for Debug::fmt Aug 14, 2020
@codecov
Copy link

codecov bot commented Aug 14, 2020

Codecov Report

Merging #630 into master will increase coverage by 0.06%.
The diff coverage is 95.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #630      +/-   ##
==========================================
+ Coverage   72.56%   72.62%   +0.06%     
==========================================
  Files         179      179              
  Lines       13259    13279      +20     
==========================================
+ Hits         9621     9644      +23     
+ Misses       3638     3635       -3     
Impacted Files Coverage Δ
boa/src/builtins/object/gcobject.rs 84.84% <93.33%> (+7.07%) ⬆️
boa/src/builtins/value/tests.rs 100.00% <100.00%> (ø)
boa/src/builtins/function/mod.rs 73.05% <0.00%> (+2.39%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c5b708b...1bfce7c. Read the comment docs.

Copy link
Member

@Razican Razican left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like how this was done :)
I added some comments, mostly to add a bit of documentation and to maybe improve the debug output if you agree.

Thanks!

boa/src/builtins/object/gcobject.rs Outdated Show resolved Hide resolved
boa/src/builtins/object/gcobject.rs Outdated Show resolved Hide resolved
boa/src/builtins/object/gcobject.rs Outdated Show resolved Hide resolved
@Razican Razican added this to the v0.10.0 milestone Aug 14, 2020
@Razican Razican added the bug Something isn't working label Aug 14, 2020
boa/src/builtins/object/gcobject.rs Outdated Show resolved Hide resolved
boa/src/builtins/object/gcobject.rs Outdated Show resolved Hide resolved
Copy link
Member

@HalidOdat HalidOdat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks perfect to me! :)

Copy link
Member

@Razican Razican left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost ready! I just found one undocumented static.

boa/src/builtins/object/gcobject.rs Outdated Show resolved Hide resolved
@jcdickinson
Copy link
Contributor Author

Windows check failed with no logs, not sure if I can rerun it?

@HalidOdat
Copy link
Member

Windows check failed with no logs, not sure if I can rerun it?

That is strange. Ill rerun it :)

@Razican Razican merged commit 908cb3a into boa-dev:master Aug 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Debug::fmt Causes Causes a Stack Overflow
3 participants