[SR-4732] "Tree" enum crashes at runtime "cyclic metadata dependency detected, aborting" #47309
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
crash
Bug: A crash, i.e., an abnormal termination of software
run-time crash
Bug → crash: Swift code crashed during execution
runtime
The Swift Runtime
Environment
Mac Pro 5,1, macOS Sierra 10.12.4
Tested both Xcode 8.3.2 and swift-DEVELOPMENT-SNAPSHOT-2017-04-24-a-osx
Additional Detail from JIRA
md5: ff2afb9391fe46a532bd849ab2c2aca2
duplicates:
relates to:
Issue Description:
In Xcode 8.3.2 and the latest development snapshot (April 24, 2017), the following code:
crashes at runtime on the `let a = Tree` line with the error:
> GenericCache(0x100658d08): cyclic metadata dependency detected, aborting
By my understanding, this should be valid code, despite the recursive definition, since the layout of `Array` does not depend on its generic parameter.
Indeed, change the definition of `parentAndChildren` to:
and there's no problem – the code works as expected.
In addition to changing the contents of the `case`, it is possible to declare the original `parentAndChildren` case as `indirect` and the problem goes away.
Ideally, the original code should work. If that isn't possible, a compile time error (forcing the use of `indirect`) would be preferable to a runtime crash.
Previous bugs returning the same error include:
https://bugs.swift.org/browse/SR-3779
https://bugs.swift.org/browse/SR-4383
However, it's not clear if either of these are precisely the same problem.
The text was updated successfully, but these errors were encountered: