swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.32k stars 10.34k forks source link

[SR-4803] Compiler crash with recent snapshot #47380

Open swift-ci opened 7 years ago

swift-ci commented 7 years ago
Previous ID SR-4803
Radar None
Original Reporter maik (JIRA User)
Type Bug
Environment Swift snapshot from April 24, 2017 and Xcode 8.3.2
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug, CompilerCrash | |Assignee | None | |Priority | Medium | md5: f813901e44f3644c30bf33e5c9d711fc

Issue Description:

Compiling with the snapshot from April 24, 2017 the compiler crashes with the following stack trace:

0  swift                    0x000000010627aff8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x0000000106279fc6 llvm::sys::RunSignalHandlers() + 86
2  swift                    0x000000010627b5b9 SignalHandler(int) + 361
3  libsystem_platform.dylib 0x00007fff8ca36b3a _sigtramp + 26
4  libsystem_platform.dylib 0x00007fff5cb4ba18 _sigtramp + 3490795256
5  swift                    0x00000001040314b6 (anonymous namespace)::Verifier::walkToExprPost(swift::Expr*) + 4758
6  swift                    0x000000010404194e swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Expr*) + 6094
7  swift                    0x000000010404026d swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Expr*) + 237
8  swift                    0x0000000104044048 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Stmt*) + 216
9  swift                    0x0000000104046710 (anonymous namespace)::Traversal::visitAbstractFunctionDecl(swift::AbstractFunctionDecl*) + 1232
10 swift                    0x000000010403f91c (anonymous namespace)::Traversal::doIt(swift::Decl*) + 364
11 swift                    0x00000001040461c4 (anonymous namespace)::Traversal::visitNominalTypeDecl(swift::NominalTypeDecl*) + 900
12 swift                    0x000000010403f90f (anonymous namespace)::Traversal::doIt(swift::Decl*) + 351
13 swift                    0x000000010403f79b swift::Decl::walk(swift::ASTWalker&) + 27
14 swift                    0x000000010402f7bd swift::verify(swift::Decl*) + 157
15 swift                    0x0000000103cd06ab swift::ModuleFile::verify() const + 91
16 swift                    0x0000000103d1f708 swift::SerializedModuleLoader::verifyAllModules() + 40
17 swift                    0x0000000103fc2539 swift::ASTContext::verifyAllLoadedModules() const + 57
18 swift                    0x0000000103fb1d21 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int) + 2113
19 swift                    0x0000000103b46099 swift::CompilerInstance::performSema() + 3881
20 swift                    0x00000001030f8da1 performCompile(std::__1::unique_ptr<swift::CompilerInstance, std::__1::default_delete<swift::CompilerInstance> >&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 1617
21 swift                    0x00000001030f768f swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3183
22 swift                    0x00000001030b4330 main + 3312
23 libdyld.dylib            0x00007fff8c827235 start + 1
24 libdyld.dylib            0x0000000000000044 start + 1937608208

and the following message at the bottom of the log:

While walking into body of 'init' in module 'Foundation'

I cannot share the project and have not currently found a way to reproduce the issue. Is there something else I could do?

belkadan commented 7 years ago

Is your module named "Foundation", or is it referring to the Foundation you've imported? (You're not supposed to use the same names as system modules.)

swift-ci commented 7 years ago

Comment by Maik Bastian (JIRA)

There is no module named Foundation inside the project. It is referring to an import of Foundation (in some other file in the project).

swift-ci commented 7 years ago

Comment by Maik Bastian (JIRA)

While trying to find the error of SR-4739 (using a compiler with assertions enabled), I got the following error, which is maybe related to this issue:

*** DESERIALIZATION FAILURE (please include this section in any bug report) ***
result not found
Cross-reference to module 'Foundation'
... NSNotification
... in an extension in module 'Foundation'
... Name

0  swift                    0x000000011125bc5c llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 60
1  swift                    0x000000011125c1d9 PrintStackTraceSignalHandler(void*) + 25
2  swift                    0x0000000111257e89 llvm::sys::RunSignalHandlers() + 425
3  swift                    0x000000011125c672 SignalHandler(int) + 354
4  libsystem_platform.dylib 0x00007fff8ca36b3a _sigtramp + 26
5  libsystem_platform.dylib 0x0000000124ad4551 _sigtramp + 2550782513
6  libsystem_c.dylib        0x00007fff8c8bb420 abort + 129
7  swift                    0x000000010bd57ef9 swift::ModuleFile::fatal(llvm::Error) + 1161
8  swift                    0x000000010bd587a6 swift::ModuleFile::getDecl(llvm::PointerEmbeddedInt<unsigned int, 31>, llvm::Optional<swift::DeclContext*>) + 134
9  swift                    0x000000010bd78817 swift::ModuleFile::getTypeChecked(llvm::PointerEmbeddedInt<unsigned int, 31>) + 1431
10 swift                    0x000000010bd5a401 swift::ModuleFile::getType(llvm::PointerEmbeddedInt<unsigned int, 31>) + 65
11 swift                    0x000000010bd5d142 swift::ModuleFile::getDeclChecked(llvm::PointerEmbeddedInt<unsigned int, 31>, llvm::Optional<swift::DeclContext*>) + 11314
12 swift                    0x000000010bd58772 swift::ModuleFile::getDecl(llvm::PointerEmbeddedInt<unsigned int, 31>, llvm::Optional<swift::DeclContext*>) + 82
13 swift                    0x000000010bd785eb swift::ModuleFile::getTypeChecked(llvm::PointerEmbeddedInt<unsigned int, 31>) + 875
14 swift                    0x000000010bd5a401 swift::ModuleFile::getType(llvm::PointerEmbeddedInt<unsigned int, 31>) + 65
15 swift                    0x000000010bd5ea4a swift::ModuleFile::getDeclChecked(llvm::PointerEmbeddedInt<unsigned int, 31>, llvm::Optional<swift::DeclContext*>) + 17722
16 swift                    0x000000010bd59184 swift::ModuleFile::readPattern(swift::DeclContext*) + 1876
17 swift                    0x000000010bd5945c swift::ModuleFile::readPattern(swift::DeclContext*) + 2604
18 swift                    0x000000010bd6026a swift::ModuleFile::getDeclChecked(llvm::PointerEmbeddedInt<unsigned int, 31>, llvm::Optional<swift::DeclContext*>) + 23898
19 swift                    0x000000010bd68a1a swift::ModuleFile::readMembers(llvm::SmallVectorImpl<swift::Decl*>&) + 522
20 swift                    0x000000010bd7e369 swift::ModuleFile::loadAllMembers(swift::Decl*, unsigned long long) + 217
21 swift                    0x000000010c83fb6c swift::IterableDeclContext::loadAllMembers() const + 204
22 swift                    0x000000010c804269 swift::NominalTypeDecl::getMembers() const + 25
23 swift                    0x000000010c9997ce swift::NominalTypeDecl::lookupDirect(swift::DeclName, bool) + 62
24 swift                    0x000000010c9975f9 swift::DeclContext::lookupQualified(swift::Type, swift::DeclName, swift::NLOptions, swift::LazyResolver*, llvm::SmallVectorImpl<swift::ValueDecl*>&) const + 3049
25 swift                    0x000000010c4e438a swift::TypeChecker::lookupMemberType(swift::DeclContext*, swift::Type, swift::Identifier, swift::OptionSet<swift::NameLookupFlags, unsigned int>) + 490
26 swift                    0x000000010c5e8fd2 resolveNestedIdentTypeComponent(swift::TypeChecker&, swift::DeclContext*, swift::Type, swift::SourceRange, swift::ComponentIdentTypeRepr*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, bool, swift::GenericTypeResolver*, llvm::function_ref<bool (swift::TypeCheckRequest)>*) + 2178
27 swift                    0x000000010c5e1667 resolveIdentTypeComponent(swift::TypeChecker&, swift::DeclContext*, llvm::ArrayRef<swift::ComponentIdentTypeRepr*>, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, bool, swift::GenericTypeResolver*, llvm::function_ref<bool (swift::TypeCheckRequest)>*) + 759
28 swift                    0x000000010c5e1086 swift::TypeChecker::resolveIdentifierType(swift::DeclContext*, swift::IdentTypeRepr*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, bool, swift::GenericTypeResolver*, llvm::function_ref<bool (swift::TypeCheckRequest)>*) + 342
29 swift                    0x000000010c5e1f27 (anonymous namespace)::TypeResolver::resolveType(swift::TypeRepr*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>) + 727
30 swift                    0x000000010c5e1b69 swift::TypeChecker::resolveType(swift::TypeRepr*, swift::DeclContext*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, swift::GenericTypeResolver*, llvm::function_ref<bool (swift::TypeCheckRequest)>*) + 169
31 swift                    0x000000010c5dfd8d swift::TypeChecker::validateType(swift::TypeLoc&, swift::DeclContext*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, swift::GenericTypeResolver*, llvm::function_ref<bool (swift::TypeCheckRequest)>*) + 317
32 swift                    0x000000010c60023c bindExtensionDecl(swift::ExtensionDecl*, swift::TypeChecker&) + 316
33 swift                    0x000000010c60a4a1 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int)::$_2::operator()(std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*>) const + 609
34 swift                    0x000000010c60a235 void llvm::function_ref<void (std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*>)>::callback_fn<swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int)::$_2>(long, std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*>) + 85
35 swift                    0x000000010c6883d9 llvm::function_ref<void (std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*>)>::operator()(std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*>) const + 89
36 swift                    0x000000010c688366 swift::FileUnit::forAllVisibleModules(llvm::function_ref<void (std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*>)>)::'lambda'(std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*>)::operator()(std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*>) const + 166
37 swift                    0x000000010c6882b5 bool llvm::function_ref<bool (std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*>)>::callback_fn<swift::FileUnit::forAllVisibleModules(llvm::function_ref<void (std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*>)>)::'lambda'(std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*>)>(long, std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*>) + 85
38 swift                    0x000000010c9811d9 llvm::function_ref<bool (std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*>)>::operator()(std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*>) const + 89
39 swift                    0x000000010c95fd24 bool forAllImportedModules<true, llvm::function_ref<bool (std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*>)> >(swift::ModuleDecl*, llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, bool, llvm::function_ref<bool (std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*>)> const&) + 996
40 swift                    0x000000010c95f933 swift::ModuleDecl::forAllVisibleModules(llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, bool, llvm::function_ref<bool (std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*>)>) + 83
41 swift                    0x000000010c960130 bool swift::ModuleDecl::forAllVisibleModules<llvm::function_ref<bool (std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*>)>&>(llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, llvm::function_ref<bool (std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*>)>&&&) + 96
42 swift                    0x000000010c95fe48 swift::FileUnit::forAllVisibleModules(llvm::function_ref<bool (std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*>)>) + 120
43 swift                    0x000000010c6881f5 bool swift::FileUnit::forAllVisibleModules<swift::FileUnit::forAllVisibleModules(llvm::function_ref<void (std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*>)>)::'lambda'(std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*>)>(swift::FileUnit::forAllVisibleModules(llvm::function_ref<void (std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*>)>)::'lambda'(std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*>)&&) + 85
44 swift                    0x000000010c688094 swift::FileUnit::forAllVisibleModules(llvm::function_ref<void (std::__1::pair<llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*>)>) + 52
45 swift                    0x000000010c602325 bool swift::FileUnit::forAllVisibleModules<swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int)::$_2>(swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int)::$_2&&) + 85
46 swift                    0x000000010c601c34 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int) + 1092
47 swift                    0x000000010ba1acbc swift::CompilerInstance::performSema() + 14460
48 swift                    0x000000010a367ae1 performCompile(std::__1::unique_ptr<swift::CompilerInstance, std::__1::default_delete<swift::CompilerInstance> >&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 4961
49 swift                    0x000000010a3651be swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 15758
50 swift                    0x000000010a298259 main + 4809
51 libdyld.dylib            0x00007fff8c827235 start + 1

And at the bottom:

1.  While resolving type Notification.Name at [/Users/Maik/Projectname/NotificationExtensions.swift:12:11 - line:12:24] RangeText="Notification.N"
2.  While loading members for 'Notification' in module 'Foundation'
3.  While deserializing decl #&#8203;3087 (PATTERN_BINDING_DECL) in 'Foundation'
4.  While deserializing 'name' (VarDecl #&#8203;555) in 'Foundation'
5.  While deserializing 'Name' (TypeAliasDecl #&#8203;835) in 'Foundation'

The "NotificationExtensions" file contains code of this kind:

extension Notification.Name {
    static let somethingHappened = Notification.Name("SomethingHappenedNotification")
}