Open swift-ci opened 4 years ago
Looks like that Feedback hasn't made it to us yet within Apple, but can you attach the project if you haven't already? (Even better if you can share it here.)
Comment by Iulian Onofrei (JIRA)
I couldn't initially reproduce it in a project, and I couldn't share my project either. But after more trial and error, I found out the culprit, it's caused by generics with type constraints like:
@interface BaseModel<__covariant ModelType: BaseModel *> : NSObject
Replacing it with:
@interface BaseModel<__covariant ModelType> : NSObject
fixes it.
Hm, interesting. We'd probably also need to see how you use the type to track down the crash though; if you have it reproducing in a small example that'd be very useful!
cc brentdax (JIRA User)
The radar for this is still hung up in triage where I can't modify it, but I took at peek at the attachments. This looks like a pretty straightforward stack overflow due to infinite recursion in ClangImporter:
[ 1] 0x00000001084a6abd swift`::Visit() [inlined] importDecl + 12 at ImporterImpl.h:767:12
[ 1] 0x00000001084a6ab1 swift`::Visit() [inlined] VisitObjCObjectPointerType + 244 at ImportType.cpp:935
[ 1] 0x00000001084a69bd swift`::Visit() + 173 at TypeNodes.def:113
[ 2] 0x00000001084a5845 swift`::importType() [inlined] Visit + 21 at ImportType.cpp:188:17
[ 2] 0x00000001084a5830 swift`::importType() + 1408 at ImportType.cpp:1510
[ 3] 0x0000000108468740 swift`::Visit() [inlined] importTypeIgnoreIUO + 26 at ImportType.cpp:1525:23
[ 3] 0x0000000108468726 swift`::Visit() [inlined] importObjCGenericParams + 1645 at ImportDecl.cpp:6743
[ 3] 0x00000001084680b9 swift`::Visit() [inlined] VisitObjCInterfaceDecl + 277 at ImportDecl.cpp:4547
[ 3] 0x0000000108467fa4 swift`::Visit() + 10084 at DeclNodes.inc:153
[ 4] 0x0000000108464e7d swift`::importDeclAndCacheImpl() [inlined] importDeclImpl + 128 at ImportDecl.cpp:7494:24
[ 5] 0x00000001084a6abd swift`::Visit() [inlined] importDecl + 12 at ImporterImpl.h:767:12
The code has moved around a little, but I think the problem might be in VisitObjCInterfaceDecl()
, where we import the generic parameters before we add the declaration to the ImportedDecls map. I don't know ClangImporter very well yet, so maybe I'm missing something, but shouldn't we make sure the type is registered before we import something that might refer to it?
Comment by Iulian Onofrei (JIRA)
I uploaded a simple project that reproduces it, let me know if you need me to upload here too.
Environment
macOS 10.14.5 (18F132) Xcode 11.1 (11A1027)Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler, Source Tooling | |Labels | Bug, ClangImporter, CompilerCrash | |Assignee | @beccadax | |Priority | Medium | md5: 13546b5062a56d81ec4f05a0f0195c6aIssue Description:
I get this when I try to compile a project which uses Objective-C and Swift, and when I import some files (hard to tell the root cause because of nested imports) in the bridging file: