-
Notifications
You must be signed in to change notification settings - Fork 108
A cyclic graph of 3 or more items causes an infinite recursion #785
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
Comments
@stmontgomery, I think you may have a radar tracking this internally too? |
I believe I ran into the same bug, except it happens when attempting to describe the objects involved in a failed import Testing
class SelfReferential {
var optionalRefA: SelfReferential? = nil
var optionalRefB: SelfReferential? = nil
}
@Test func crasher() {
let object = SelfReferential()
object.optionalRefA = object
#expect(object !== object)
object.optionalRefB = object
#expect(object !== object)
} Swift and OS Versionswift-driver version: 1.115 Apple Swift version 6.0.2 (swiftlang-6.0.2.1.2 clang-1600.0.26.4) |
I don't believe we have a Radar for this particular symptom (a crash due to infinite recursion), but I have a fix nearly ready. |
…t's children were recursively reflected Fixes swiftlang#785
Tracked internally as rdar://138708651 |
Uh oh!
There was an error while loading. Please reload this page.
Description
Initializing an
argument
that contains 3 or more cyclical classes causes an infinite recursion within__Expression.Value
's private init:I tracked it down to the attempt to prevent cyclical dependencies. Using the sample code provided in Steps to Reproduce, I was able to maybe fix this by removing the
defer
and adding afilter
onto the children:But I'm unsure if this has any unintended side effects (specifically, the comment callout about multiple references to the same object in the same subject). Logging a
Value(reflecting: a)
in themakeA()
method returns me aValue
instance that looks to properly stop traversing future references of the same type after it traverses first one.Expected behavior
Cyclical graphs of any complexity should resolve their reflection correctly
Actual behavior
Once 3 classes are introduced into the graph, the initializer enters an infinite loop
Steps to reproduce
makeA()
and before the main test beginsswift-testing version/commit hash
Xcode's version of swift-testing
Swift & OS version (output of
swift --version ; uname -a
)swift-driver version: 1.115 Apple Swift version 6.0.2 (swiftlang-6.0.2.1.2 clang-1600.0.26.4)
Target: arm64-apple-macosx15.0
Darwin .local 24.2.0 Darwin Kernel Version 24.2.0: Tue Oct 15 18:15:36 PDT 2024; root:xnu-11215.60.364.501.5~3/RELEASE_ARM64_T6000 arm64
The text was updated successfully, but these errors were encountered: