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-5231] Compiler crash. DESERIALIZATION FAILURE Cross-reference to module 'CoreFoundation' #47806

Open
swift-ci opened this issue Jun 15, 2017 · 4 comments
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 serialization Area → compiler: Serialization & deserialization

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-5231
Radar rdar://problem/32816448
Original Reporter carlb (JIRA User)
Type Bug

Attachment: Download

Environment

macOS 10.11 with Xcode9 (although it happens in 8.3 as well).

Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug, CompilerCrash, Serialization
Assignee None
Priority Medium

md5: 131a90e9af59af87951bc1f43e946301

Issue Description:

This is a compiler crash that I discussed at WWDC 2017 with Doug Gregor and Phillipe Hausler.

The simplest repro case I've found is at https://github.com/carlbrown/CorelibsCompilerCrash

If you comment out the `X` from the last line of `main.swift`, it will compile. If you leave it in, you get the following crash:

CompileSwift normal x86_64 /Users/carlbrown/Documents/ForRadar/CorelibsCompilerCrash/CorelibsCompilerCrash/main.swift
    cd /Users/carlbrown/Documents/ForRadar/CorelibsCompilerCrash
    /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file /Users/carlbrown/Documents/ForRadar/CorelibsCompilerCrash/CorelibsCompilerCrash/main.swift -target x86_64-apple-macosx10.12 -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -I /Users/carlbrown/Library/Developer/Xcode/DerivedData/CorelibsCompilerCrash-bpnrxdcazwbilycxiydpmufesotl/Build/Products/Debug -F /Users/carlbrown/Library/Developer/Xcode/DerivedData/CorelibsCompilerCrash-bpnrxdcazwbilycxiydpmufesotl/Build/Products/Debug -enable-testing -g -module-cache-path /Users/carlbrown/Library/Developer/Xcode/DerivedData/ModuleCache -swift-version 3 -D SWIFT_PACKAGE -D Xcode -serialize-debugging-options -Xcc -I/Users/carlbrown/Library/Developer/Xcode/DerivedData/CorelibsCompilerCrash-bpnrxdcazwbilycxiydpmufesotl/Build/Intermediates.noindex/CorelibsCompilerCrash.build/Debug/CorelibsCompilerCrash.build/swift-overrides.hmap -Xcc -I/Users/carlbrown/Library/Developer/Xcode/DerivedData/CorelibsCompilerCrash-bpnrxdcazwbilycxiydpmufesotl/Build/Products/Debug/include -Xcc -I/Users/carlbrown/Library/Developer/Xcode/DerivedData/CorelibsCompilerCrash-bpnrxdcazwbilycxiydpmufesotl/Build/Intermediates.noindex/CorelibsCompilerCrash.build/Debug/CorelibsCompilerCrash.build/DerivedSources/x86_64 -Xcc -I/Users/carlbrown/Library/Developer/Xcode/DerivedData/CorelibsCompilerCrash-bpnrxdcazwbilycxiydpmufesotl/Build/Intermediates.noindex/CorelibsCompilerCrash.build/Debug/CorelibsCompilerCrash.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -working-directory/Users/carlbrown/Documents/ForRadar/CorelibsCompilerCrash -emit-module-doc-path /Users/carlbrown/Library/Developer/Xcode/DerivedData/CorelibsCompilerCrash-bpnrxdcazwbilycxiydpmufesotl/Build/Intermediates.noindex/CorelibsCompilerCrash.build/Debug/CorelibsCompilerCrash.build/Objects-normal/x86_64/main~partial.swiftdoc -serialize-diagnostics-path /Users/carlbrown/Library/Developer/Xcode/DerivedData/CorelibsCompilerCrash-bpnrxdcazwbilycxiydpmufesotl/Build/Intermediates.noindex/CorelibsCompilerCrash.build/Debug/CorelibsCompilerCrash.build/Objects-normal/x86_64/main.dia -Onone -module-name CorelibsCompilerCrash -emit-module-path /Users/carlbrown/Library/Developer/Xcode/DerivedData/CorelibsCompilerCrash-bpnrxdcazwbilycxiydpmufesotl/Build/Intermediates.noindex/CorelibsCompilerCrash.build/Debug/CorelibsCompilerCrash.build/Objects-normal/x86_64/main~partial.swiftmodule -emit-dependencies-path /Users/carlbrown/Library/Developer/Xcode/DerivedData/CorelibsCompilerCrash-bpnrxdcazwbilycxiydpmufesotl/Build/Intermediates.noindex/CorelibsCompilerCrash.build/Debug/CorelibsCompilerCrash.build/Objects-normal/x86_64/main.d -emit-reference-dependencies-path /Users/carlbrown/Library/Developer/Xcode/DerivedData/CorelibsCompilerCrash-bpnrxdcazwbilycxiydpmufesotl/Build/Intermediates.noindex/CorelibsCompilerCrash.build/Debug/CorelibsCompilerCrash.build/Objects-normal/x86_64/main.swiftdeps -o /Users/carlbrown/Library/Developer/Xcode/DerivedData/CorelibsCompilerCrash-bpnrxdcazwbilycxiydpmufesotl/Build/Intermediates.noindex/CorelibsCompilerCrash.build/Debug/CorelibsCompilerCrash.build/Objects-normal/x86_64/main.o -index-store-path /Users/carlbrown/Library/Developer/Xcode/DerivedData/CorelibsCompilerCrash-bpnrxdcazwbilycxiydpmufesotl/Index/DataStore -index-system-modules

<unknown>:0: error: fatal error encountered while reading from module 'SwiftFoundation'; please file a bug report with your project and the crash log

*** DESERIALIZATION FAILURE (please include this section in any bug report) ***
top-level value not found
Cross-reference to module 'CoreFoundation'
... _CFXMLInterface

0  swift                    0x000000010a91b3aa PrintStackTraceSignalHandler(void*) + 42
1  swift                    0x000000010a91a7e6 SignalHandler(int) + 662
2  libsystem_platform.dylib 0x00007fffa7a1eb3a _sigtramp + 26
3  libsystem_platform.dylib 0x0000000115358551 _sigtramp + 1838389809
4  libsystem_c.dylib        0x00007fffa78a3420 abort + 129
5  swift                    0x0000000108031ea1 swift::ModuleFile::fatal(llvm::Error) + 1569
6  swift                    0x000000010803c549 swift::ModuleFile::getDeclChecked(llvm::PointerEmbeddedInt<unsigned int, 31>, llvm::Optional<swift::DeclContext*>) + 41449
7  swift                    0x000000010806a3bb swift::ModuleFile::lookupVisibleDecls(llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::VisibleDeclConsumer&, swift::NLKind)::$_1::operator()(llvm::PointerEmbeddedInt<unsigned int, 31>) const + 43
8  swift                    0x00000001080d3c1e swift::SerializedASTFile::lookupVisibleDecls(llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::VisibleDeclConsumer&, swift::NLKind) const + 590
9  swift                    0x00000001084e5405 void lookupInModule<llvm::DenseMap<swift::Identifier, std::__1::pair<swift::namelookup::ResolutionKind, llvm::SmallSet<swift::CanType, 4u, (anonymous namespace)::SortCanType> >, llvm::DenseMapInfo<swift::Identifier>, llvm::detail::DenseMapPair<swift::Identifier, std::__1::pair<swift::namelookup::ResolutionKind, llvm::SmallSet<swift::CanType, 4u, (anonymous namespace)::SortCanType> > > >, swift::namelookup::lookupVisibleDeclsInModule(swift::ModuleDecl*, llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, llvm::SmallVectorImpl<swift::ValueDecl*>&, swift::NLKind, swift::namelookup::ResolutionKind, swift::LazyResolver*, swift::DeclContext const*, llvm::ArrayRef<std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*> >)::$_1>(swift::ModuleDecl*, llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, llvm::SmallVectorImpl<swift::ValueDecl*>&, swift::namelookup::ResolutionKind, bool, swift::LazyResolver*, llvm::SmallDenseMap<std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*>, llvm::TinyPtrVector<swift::ValueDecl*>, 32u, llvm::DenseMapInfo<std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*> >, llvm::detail::DenseMapPair<std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*>, llvm::TinyPtrVector<swift::ValueDecl*> > >&, swift::DeclContext const*, bool, llvm::ArrayRef<std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*> >, swift::namelookup::lookupVisibleDeclsInModule(swift::ModuleDecl*, llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, llvm::SmallVectorImpl<swift::ValueDecl*>&, swift::NLKind, swift::namelookup::ResolutionKind, swift::LazyResolver*, swift::DeclContext const*, llvm::ArrayRef<std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*> >)::$_1) + 341
10 swift                    0x00000001084e5961 void lookupInModule<llvm::DenseMap<swift::Identifier, std::__1::pair<swift::namelookup::ResolutionKind, llvm::SmallSet<swift::CanType, 4u, (anonymous namespace)::SortCanType> >, llvm::DenseMapInfo<swift::Identifier>, llvm::detail::DenseMapPair<swift::Identifier, std::__1::pair<swift::namelookup::ResolutionKind, llvm::SmallSet<swift::CanType, 4u, (anonymous namespace)::SortCanType> > > >, swift::namelookup::lookupVisibleDeclsInModule(swift::ModuleDecl*, llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, llvm::SmallVectorImpl<swift::ValueDecl*>&, swift::NLKind, swift::namelookup::ResolutionKind, swift::LazyResolver*, swift::DeclContext const*, llvm::ArrayRef<std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*> >)::$_1>(swift::ModuleDecl*, llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, llvm::SmallVectorImpl<swift::ValueDecl*>&, swift::namelookup::ResolutionKind, bool, swift::LazyResolver*, llvm::SmallDenseMap<std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*>, llvm::TinyPtrVector<swift::ValueDecl*>, 32u, llvm::DenseMapInfo<std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*> >, llvm::detail::DenseMapPair<std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*>, llvm::TinyPtrVector<swift::ValueDecl*> > >&, swift::DeclContext const*, bool, llvm::ArrayRef<std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*> >, swift::namelookup::lookupVisibleDeclsInModule(swift::ModuleDecl*, llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, llvm::SmallVectorImpl<swift::ValueDecl*>&, swift::NLKind, swift::namelookup::ResolutionKind, swift::LazyResolver*, swift::DeclContext const*, llvm::ArrayRef<std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*> >)::$_1) + 1713
11 swift                    0x00000001084d33ed swift::lookupVisibleDecls(swift::VisibleDeclConsumer&, swift::DeclContext const*, swift::LazyResolver*, bool, swift::SourceLoc) + 3629
12 swift                    0x00000001083853b6 swift::TypeChecker::performTypoCorrection(swift::DeclContext*, swift::DeclRefKind, swift::Type, swift::DeclName, swift::SourceLoc, swift::OptionSet<swift::NameLookupFlags, unsigned int>, swift::LookupResult&, unsigned int) + 342
13 swift                    0x0000000108336ceb swift::TypeChecker::resolveDeclRefExpr(swift::UnresolvedDeclRefExpr*, swift::DeclContext*) + 1035
14 swift                    0x000000010833c448 (anonymous namespace)::PreCheckExpression::walkToExprPre(swift::Expr*) + 1160
15 swift                    0x000000010833a58d swift::TypeChecker::solveForExpression(swift::Expr*&, swift::DeclContext*, swift::Type, swift::FreeTypeVariableBinding, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem&, llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 205
16 swift                    0x000000010833f3ea swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem*) + 986
17 swift                    0x00000001083c3a3d swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 13789
18 swift                    0x00000001083c654c swift::TypeChecker::typeCheckTopLevelCodeDecl(swift::TopLevelCodeDecl*) + 220
19 swift                    0x00000001083e2275 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int) + 1765
20 swift                    0x0000000107f3f924 swift::CompilerInstance::performSema() + 4612
21 swift                    0x00000001072ea0cb performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 1371
22 swift                    0x00000001072e8304 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7332
23 swift                    0x000000010729e728 main + 12248
24 libdyld.dylib            0x00007fffa780f235 start + 1
25 libdyld.dylib            0x0000000000000037 start + 1484721667
Stack dump:
0.  Program arguments: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file /Users/carlbrown/Documents/ForRadar/CorelibsCompilerCrash/CorelibsCompilerCrash/main.swift -target x86_64-apple-macosx10.12 -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -I /Users/carlbrown/Library/Developer/Xcode/DerivedData/CorelibsCompilerCrash-bpnrxdcazwbilycxiydpmufesotl/Build/Products/Debug -F /Users/carlbrown/Library/Developer/Xcode/DerivedData/CorelibsCompilerCrash-bpnrxdcazwbilycxiydpmufesotl/Build/Products/Debug -enable-testing -g -module-cache-path /Users/carlbrown/Library/Developer/Xcode/DerivedData/ModuleCache -swift-version 3 -D SWIFT_PACKAGE -D Xcode -serialize-debugging-options -Xcc -I/Users/carlbrown/Library/Developer/Xcode/DerivedData/CorelibsCompilerCrash-bpnrxdcazwbilycxiydpmufesotl/Build/Intermediates.noindex/CorelibsCompilerCrash.build/Debug/CorelibsCompilerCrash.build/swift-overrides.hmap -Xcc -I/Users/carlbrown/Library/Developer/Xcode/DerivedData/CorelibsCompilerCrash-bpnrxdcazwbilycxiydpmufesotl/Build/Products/Debug/include -Xcc -I/Users/carlbrown/Library/Developer/Xcode/DerivedData/CorelibsCompilerCrash-bpnrxdcazwbilycxiydpmufesotl/Build/Intermediates.noindex/CorelibsCompilerCrash.build/Debug/CorelibsCompilerCrash.build/DerivedSources/x86_64 -Xcc -I/Users/carlbrown/Library/Developer/Xcode/DerivedData/CorelibsCompilerCrash-bpnrxdcazwbilycxiydpmufesotl/Build/Intermediates.noindex/CorelibsCompilerCrash.build/Debug/CorelibsCompilerCrash.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -working-directory/Users/carlbrown/Documents/ForRadar/CorelibsCompilerCrash -emit-module-doc-path /Users/carlbrown/Library/Developer/Xcode/DerivedData/CorelibsCompilerCrash-bpnrxdcazwbilycxiydpmufesotl/Build/Intermediates.noindex/CorelibsCompilerCrash.build/Debug/CorelibsCompilerCrash.build/Objects-normal/x86_64/main~partial.swiftdoc -serialize-diagnostics-path /Users/carlbrown/Library/Developer/Xcode/DerivedData/CorelibsCompilerCrash-bpnrxdcazwbilycxiydpmufesotl/Build/Intermediates.noindex/CorelibsCompilerCrash.build/Debug/CorelibsCompilerCrash.build/Objects-normal/x86_64/main.dia -Onone -module-name CorelibsCompilerCrash -emit-module-path /Users/carlbrown/Library/Developer/Xcode/DerivedData/CorelibsCompilerCrash-bpnrxdcazwbilycxiydpmufesotl/Build/Intermediates.noindex/CorelibsCompilerCrash.build/Debug/CorelibsCompilerCrash.build/Objects-normal/x86_64/main~partial.swiftmodule -emit-dependencies-path /Users/carlbrown/Library/Developer/Xcode/DerivedData/CorelibsCompilerCrash-bpnrxdcazwbilycxiydpmufesotl/Build/Intermediates.noindex/CorelibsCompilerCrash.build/Debug/CorelibsCompilerCrash.build/Objects-normal/x86_64/main.d -emit-reference-dependencies-path /Users/carlbrown/Library/Developer/Xcode/DerivedData/CorelibsCompilerCrash-bpnrxdcazwbilycxiydpmufesotl/Build/Intermediates.noindex/CorelibsCompilerCrash.build/Debug/CorelibsCompilerCrash.build/Objects-normal/x86_64/main.swiftdeps -o /Users/carlbrown/Library/Developer/Xcode/DerivedData/CorelibsCompilerCrash-bpnrxdcazwbilycxiydpmufesotl/Build/Intermediates.noindex/CorelibsCompilerCrash.build/Debug/CorelibsCompilerCrash.build/Objects-normal/x86_64/main.o -index-store-path /Users/carlbrown/Library/Developer/Xcode/DerivedData/CorelibsCompilerCrash-bpnrxdcazwbilycxiydpmufesotl/Index/DataStore -index-system-modules 
1.  While type-checking expression at [/Users/carlbrown/Documents/ForRadar/CorelibsCompilerCrash/CorelibsCompilerCrash/main.swift:12:1 - line:12:1] RangeText="u"
2.  While reading from /Users/carlbrown/Library/Developer/Xcode/DerivedData/CorelibsCompilerCrash-bpnrxdcazwbilycxiydpmufesotl/Build/Products/Debug/SwiftFoundation.framework/Modules/SwiftFoundation.swiftmodule/x86_64.swiftmodule
3.  While deserializing '_NSXMLParserStartElementNs' (FuncDecl #&#8203;343) in 'SwiftFoundation'
@swift-ci
Copy link
Collaborator Author

Comment by Carl Brown (JIRA)

Just to set the stage - what I'm trying to do is make it easier for people (like me) to link apps against SwiftFoundation on the Mac. This way we can use the Mac's MUCH BETTER tools (Instruments.app FTW) to profile and fix bugs in swift-corelibs-foundation.

This bug makes it REALLY hard, because any syntax error causes a compiler crash instead of an error message, so work takes forever.

@belkadan
Copy link
Contributor

Thanks for the reduced test case!

@swift-ci create

@weissi
Copy link
Member

weissi commented Aug 22, 2017

hitting this too :\

@swift-ci
Copy link
Collaborator Author

Comment by Marcus Kida (JIRA)

I'm hitting this issue as well with Xcode 9.3 and a Swift macOS project, filed as rdar://39444122

@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
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 serialization Area → compiler: Serialization & deserialization
Projects
None yet
Development

No branches or pull requests

4 participants