Skip to content

Ensure the identifier of a "seen" object is only removed if the object's children were recursively reflected #787

New issue

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

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

Already on GitHub? # to your account

Merged
merged 1 commit into from
Oct 28, 2024

Conversation

stmontgomery
Copy link
Contributor

This fixes a crash which can occur if an object has certain cyclic references and it's included in an expectation expression which fails.

The bug is that the identifier of a "seen" object passed to Expression.Value.init(_reflecting:label:seenObjects:) should only be removed from the tracking dictionary if the object's children were recursively reflected. If recursion did not occur, that indicates that the object has been seen so it should be left in the tracking dictionary to prevent subsequent recursion. I added new unit tests to validate this.

Fixes #785

Result:

The scenarios described in #785 no longer crash.

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

@stmontgomery stmontgomery added bug 🪲 Something isn't working tools integration Integration of swift-testing into tools/IDEs labels Oct 28, 2024
@stmontgomery stmontgomery added this to the Swift 6.1 milestone Oct 28, 2024
@stmontgomery stmontgomery self-assigned this Oct 28, 2024
@stmontgomery
Copy link
Contributor Author

@swift-ci please test

var objectIdentifierTeRemove: ObjectIdentifier?
var objectIdentifierToRemove: ObjectIdentifier?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Drive by typo and style fixes here and above

@grynspan grynspan added the issue-handling Related to Issue handling within the testing library label Oct 28, 2024
@stmontgomery stmontgomery merged commit 5f166be into swiftlang:main Oct 28, 2024
3 checks passed
@stmontgomery stmontgomery deleted the value-inf-recursion-fix branch October 28, 2024 20:53
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug 🪲 Something isn't working issue-handling Related to Issue handling within the testing library tools integration Integration of swift-testing into tools/IDEs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A cyclic graph of 3 or more items causes an infinite recursion
3 participants