Skip to content

Fix bug handling cyclic diagnostics.#31960

Merged
jacob314 merged 1 commit intoflutter:masterfrom
jacob314:fix_inspector
May 2, 2019
Merged

Fix bug handling cyclic diagnostics.#31960
jacob314 merged 1 commit intoflutter:masterfrom
jacob314:fix_inspector

Conversation

@jacob314
Copy link
Contributor

@jacob314 jacob314 commented May 2, 2019

Description

Cases where there was a cycle involving diagnostics referenced in a property and their properties could cause some InspectorService methods to stack overflow.

Related Issues

This pull request fixes
#31959

Tests

I added the following tests:

I added a test that reproduces the cyclic diagnostic without having to depend on the specific Diagnosticables that currently have cyclic dependencies and then make the test pass by fixing the bug.

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require Flutter developers to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (Please read Handling breaking changes). Replace this with a link to the e-mail where you asked for input on this proposed change.
  • No, this is not a breaking change.

@jacob314 jacob314 requested a review from goderbauer May 2, 2019 02:23
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using the type of the value is more useful in this case as you can't expand a null value anyway. My test was failing until I fixed this somewhat minor bug.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was the problem case. The fix could have been just to remove these 4 lines which I added in error. They are not safe as cycles between property values and their properties could lead to a stack overflow.

Inspecting this code I also noticed the previous code could sometimes override the json['properties'] field if a DiagnosticsProperty subclass returned properties as well has having a value that was Diagnosticable so I cleaned that case up.

expect(location.file, equals(file));
// ClockText widget.
expect(location.line, equals(50));
expect(location.line, equals(51));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had to update these line #s due to the added import at the top of the file.

@jacob314 jacob314 merged commit e17f9e8 into flutter:master May 2, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants