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

[SR-4383] Runtime Error: cyclic metadata dependency detected, aborting #46962

Closed
SusanDoggie opened this issue Mar 28, 2017 · 7 comments
Closed
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself 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

Comments

@SusanDoggie
Copy link
Contributor

Previous ID SR-4383
Radar None
Original Reporter @SusanDoggie
Type Bug
Status Resolved
Resolution Duplicate

Attachment: Download

Environment

Xcode 8.3

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, RunTimeCrash, Runtime
Assignee None
Priority Medium

md5: 55aa64f1ae8697e9ffe1fd6b49722f36

duplicates:

  • SR-263 Implement a general solution to prevent deadlocks when generic types rely on their own metadata recursively

relates to:

  • SR-1686 Program with recursive class crashes because of “cyclic metadata dependency”

Issue Description:

generic structure extension with concrete type in framework cause runtime error:
GenericCache(0x109f18720): cyclic metadata dependency detected, aborting

@belkadan
Copy link
Contributor

It would be nice if we printed which metadata had a cycle. cc @jckarter, @rjmccall

@SusanDoggie
Copy link
Contributor Author

Is there any workarounds? The bug stop me using Swift 3.1 for development.

@belkadan
Copy link
Contributor

belkadan commented Apr 3, 2017

This error means you're already outside of valid Swift code. If code was accepted in 3.0 that is now causing this error in 3.1, that's a problem, but it's not something that was ever guaranteed to work.

If you look at the stack trace for the crash, you might be able to find out which types are causing the problem.

@SusanDoggie
Copy link
Contributor Author

not exactly

i have minimised the project and it can reproduce the bug

@SusanDoggie
Copy link
Contributor Author

I found that it fixes the problem if I move the enum Base to the outside of Bezier structure

@belkadan
Copy link
Contributor

belkadan commented Apr 4, 2017

Huh. It's unfortunate that that runs afoul of the cyclic metadata check, but I think not a surprise today. The layout of 'Bezier' depends on the layout of 'Base', but the metadata for 'Base' has a "parent" pointer that refers to the metadata for 'Bezier'. We ought to be able to handle this since the parent pointer isn't used for layout, but we currently cannot.

@ctxppc
Copy link

ctxppc commented Jun 11, 2017

I had the same problem, also involving an enum type contained in a struct type. Since it’s apparently a problem with layout, I thought I’d add the “indirect” keyword to that inner enum to decouple the enum layout from the rest, which resolved the issue. Unit tests in my project pass.

Given that my enum uses stdlib types only for associated values, there’s no recursive reference back to the enum. Is “indirect” the recommend way to go in an “ideal” compiler? I wouldn’t want to resolve to “indirect” (seems like a hack) unless that’s intended behaviour in the model.

In any case, a more detailed diagnostic of cycles would be great. :-)

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself 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
Projects
None yet
Development

No branches or pull requests

4 participants