Compiler crash

Has anyone else seen anything like this?


Assertion failed: (D->getSourceRange().isValid()), function buildDeclarationRefinementContext, file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-700.0.38.1/src/swift/lib/Sema/TypeChecker.cpp, line 946.
0  swift                    0x0000000109a08e0b llvm::sys::PrintStackTrace(__sFILE*) + 43
1  swift                    0x0000000109a0954b SignalHandler(int) + 379
2  libsystem_platform.dylib 0x00007fff8b16cf1a _sigtramp + 26
3  libsystem_platform.dylib 000000000000000000 _sigtramp + 1961439488
4  libsystem_c.dylib        0x00007fff96a5bb53 abort + 129
5  libsystem_c.dylib        0x00007fff96a23c39 basename + 0
6  swift                    0x000000010806de92 (anonymous namespace)::TypeRefinementContextBuilder::walkToDeclPre(swift::Decl*) + 1058
7  swift                    0x000000010813cf5d (anonymous namespace)::Traversal::doIt(swift::Decl*) + 157
8  swift                    0x0000000108141244 (anonymous namespace)::Traversal::visitNominalTypeDecl(swift::NominalTypeDecl*) + 164
9  swift                    0x000000010813cfb2 (anonymous namespace)::Traversal::doIt(swift::Decl*) + 242
10 swift                    0x000000010813ceab swift::Decl::walk(swift::ASTWalker&) + 27
11 swift                    0x0000000108067a19 swift::TypeChecker::buildTypeRefinementContextHierarchy(swift::SourceFile&, unsigned int) + 329
12 swift                    0x000000010806750d swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int) + 1213
13 swift                    0x0000000107e7a635 swift::CompilerInstance::performSema() + 4341
14 swift                    0x0000000107a205b0 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&) + 736
15 swift                    0x0000000107a200b3 frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 2515
16 swift                    0x0000000107a1c28f main + 1983
17 libdyld.dylib            0x00007fff88fcb5c9 start + 1


It seems to be caused by a no longer included SWIFT_WHOLE_MODULE_OPTIMIZATION = YES in the User Defined build settings.


Using the new build option for Whole Module Optimization results in the same crash.


Filed: rdar://21365971

It would be more informative if you could also provide a minimal code example that results in this.

As it was a build flag that is causing this, I went to create a project from scratch, but the option is no longet showing up in the build settings.


In the old project, I have a `SWIFT_WHOLE_MODULE_OPTIMIZATION` option in the `User Defined` setion of the Build Settings.


Not sure what to think of that.

That's not the way you would usually activate whole module optimization (neither in Xcode6 or Xcode 7).


In Xcode 7 it's in the Build Settings section: Swift Compiler - Code Generation -> Optimization Level.


In Xcode 6 there was a check box in the Swift Compiler section, if i remember correctly.


From the command line it's eg swiftc -O -whole-module-optimization main.swift

I am seeing this problem as well when I activate whole module optimization in Build Settings.


Since I have a ton of Swift files on the command line (shown in the dump), I was wondering if there was a way to tell the compiler to indicate which particular file it was working on just before the crash happens?


----------------------------------------------------------------------

Assertion failed: (D->getSourceRange().isValid()), function buildDeclarationRefinementContext, file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-700.0.38.1/src/swift/lib/Sema/TypeChecker.cpp, line 946.

0 swift 0x000000010378ae0b llvm::sys::PrintStackTrace(__sFILE*) + 43

1 swift 0x000000010378b54b SignalHandler(int) + 379

2 libsystem_platform.dylib 0x00007fff8b2adf1a _sigtramp + 26

3 libsystem_platform.dylib 000000000000000000 _sigtramp + 1960124672

4 libsystem_c.dylib 0x00007fff8fe4cb53 abort + 129

5 libsystem_c.dylib 0x00007fff8fe14c39 basename + 0

6 swift 0x0000000101defe92 (anonymous namespace)::TypeRefinementContextBuilder::walkToDeclPre(swift::Decl*) + 1058

7 swift 0x0000000101ebef5d (anonymous namespace)::Traversal::doIt(swift::Decl*) + 157

8 swift 0x0000000101ec3244 (anonymous namespace)::Traversal::visitNominalTypeDecl(swift::NominalTypeDecl*) + 164

9 swift 0x0000000101ebefb2 (anonymous namespace)::Traversal::doIt(swift::Decl*) + 242

10 swift 0x0000000101ebeeab swift::Decl::walk(swift::ASTWalker&) + 27

11 swift 0x0000000101de9a19 swift::TypeChecker::buildTypeRefinementContextHierarchy(swift::SourceFile&, unsigned int) + 329

12 swift 0x0000000101de950d swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int) + 1213

13 swift 0x0000000101bfc635 swift::CompilerInstance::performSema() + 4341

14 swift 0x00000001017a25b0 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&) + 736

15 swift 0x00000001017a20b3 frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 2515

16 swift 0x000000010179e28f main + 1983

17 libdyld.dylib 0x00007fff926365c9 start + 1

18 libdyld.dylib 0x0000000000000181 start + 1838980025

Turning on the option in the code generation options has the same effect, so the User Flag must have been the result of migrating from an old version of Xcode.

As an update, I tried enabling the module optimization on another, smaller project, and it does not result in a crash.


In my crashing project I am mixing objc and swift modules. I wonder if that could be it.

Nope, a very simple test does not induce the crash.

This error does not make any sense. I have been turning my source code around for more that 6 hours now. Commenting and de-commenting lines out. The moment that I believe I found the source and try to work around it then it comes back again.


I have narrow it down to a objective c class from an old framework. When I use this class then the error appears. Tried to comment everything out on the class and make it empty (together with references to it...huge f..... process) it compiled, then i tried to move back piece by piece. When I got the error i moved back a step. Though I got there and then error again, same comments that got me no error.


I will stop for now and probably trnaslate the framework to swift. I wish i would have done that 6 hours ago, it would be ready now.


APPLE PLEASE GIVE US SOME DETAILS ON WHICH LINE OF CODE TRIGGERS YOUR COMPILER TO GO MAD.

Compiler crash
 
 
Q