Assertion Failure When Using the swift-DEVELOPMENT-SNAPSHOT-2016-08-04-a Xcode Toolchain

Hello Swift Users,

This afternoon I updated my Xcode to Xcode 8 beta 4, and tried to compile one of my previously migrated Swift 3 projects. Along with a couple of renames, the compiler kept crashing due to a segmentation fault. Since the issue appeared to be similar to SR-2227, which was supposedly fixed with a pull request a couple days ago, I downloaded today’s snapshot toolchain. The new toolchain throws an assertion:

Assertion failed: (value != OpenExistentials.end() && "didn't see this OVE in a containing OpenExistentialExpr?"), function walkToExprPre, file /Users/buildnode/jenkins/workspace/oss-swift-package-osx/swift/lib/Sema/CSDiag.cpp, line 3082.
0 swift 0x000000010a932ebb llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43
1 swift 0x000000010a932106 llvm::sys::RunSignalHandlers() + 70
2 swift 0x000000010a93360f SignalHandler(int) + 383
3 libsystem_platform.dylib 0x00007fffa6122d7a _sigtramp + 26
4 libsystem_platform.dylib 0x0000000100000001 _sigtramp + 1508758177
5 swift 0x000000010a93335e abort + 14
6 swift 0x000000010a933341 __assert_rtn + 81
7 swift 0x0000000108431879 eraseOpenedExistentials(swift::Expr*&)::ExistentialEraser::walkToExprPre(swift::Expr*) + 361
8 swift 0x00000001085b8ea5 (anonymous namespace)::Traversal::visit(swift::Expr*) + 4981
9 swift 0x00000001085b6f75 swift::Expr::walk(swift::ASTWalker&) + 53
10 swift 0x000000010842e375 (anonymous namespace)::FailureDiagnosis::typeCheckChildIndependently(swift::Expr*, swift::Type, swift::ContextualTypePurpose, swift::OptionSet<TCCFlags, unsigned int>, swift::ExprTypeCheckListener*) + 1221
11 swift 0x0000000108434ea3 (anonymous namespace)::FailureDiagnosis::typeCheckArgumentChildIndependently(swift::Expr*, swift::Type, (anonymous namespace)::CalleeCandidateInfo const&, swift::OptionSet<TCCFlags, unsigned int>) + 1987
12 swift 0x000000010843e9a1 (anonymous namespace)::FailureDiagnosis::visitApplyExpr(swift::ApplyExpr*) + 913
13 swift 0x0000000108428f6a swift::ASTVisitor<(anonymous namespace)::FailureDiagnosis, bool, void, void, void, void, void>::visit(swift::Expr*) + 170
14 swift 0x0000000108422888 swift::constraints::ConstraintSystem::diagnoseFailureForExpr(swift::Expr*) + 104
15 swift 0x00000001084289a8 swift::constraints::ConstraintSystem::salvage(llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::Expr*) + 4056
16 swift 0x00000001084ab665 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>) + 917
17 swift 0x00000001084b17d1 swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem*) + 625
18 swift 0x000000010852c061 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 545
19 swift 0x000000010852c543 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 1795
20 swift 0x000000010852bf8e swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 334
21 swift 0x000000010852b369 (anonymous namespace)::StmtChecker::typeCheckBody(swift::BraceStmt*&) + 25
22 swift 0x000000010852a63f swift::TypeChecker::typeCheckFunctionBodyUntil(swift::FuncDecl*, swift::SourceLoc) + 383
23 swift 0x000000010852a463 swift::TypeChecker::typeCheckAbstractFunctionBodyUntil(swift::AbstractFunctionDecl*, swift::SourceLoc) + 35
24 swift 0x000000010852afe4 swift::TypeChecker::typeCheckAbstractFunctionBody(swift::AbstractFunctionDecl*) + 180
25 swift 0x00000001084e5c56 typeCheckFunctionsAndExternalDecls(swift::TypeChecker&) + 166
26 swift 0x00000001084e68f0 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int) + 1568
27 swift 0x000000010818798c swift::CompilerInstance::performSema() + 3916
28 swift 0x0000000107c82ad1 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*) + 449
29 swift 0x0000000107c8163f swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2895
30 swift 0x0000000107c43ea0 main + 2448
31 libdyld.dylib 0x00007fffa5f16255 start + 1

The stack trace doesn’t really help tell me what’s going wrong; does anyone have the same issue or know why this is happening?

Thanks,
Saagar Jha

P.S. Should I file a bug on the JIRA?

Hello Swift Users,

This afternoon I updated my Xcode to Xcode 8 beta 4, and tried to compile one of my previously migrated Swift 3 projects. Along with a couple of renames, the compiler kept crashing due to a segmentation fault. Since the issue appeared to be similar to SR-2227, which was supposedly fixed with a pull request a couple days ago, I downloaded today’s snapshot toolchain. The new toolchain throws an assertion:

Assertion failed: (value != OpenExistentials.end() && "didn't see this OVE in a containing OpenExistentialExpr?"), function walkToExprPre, file /Users/buildnode/jenkins/workspace/oss-swift-package-osx/swift/lib/Sema/CSDiag.cpp, line 3082.
0 swift 0x000000010a932ebb llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43
1 swift 0x000000010a932106 llvm::sys::RunSignalHandlers() + 70
2 swift 0x000000010a93360f SignalHandler(int) + 383
3 libsystem_platform.dylib 0x00007fffa6122d7a _sigtramp + 26
4 libsystem_platform.dylib 0x0000000100000001 _sigtramp + 1508758177
5 swift 0x000000010a93335e abort + 14
6 swift 0x000000010a933341 __assert_rtn + 81
7 swift 0x0000000108431879 eraseOpenedExistentials(swift::Expr*&)::ExistentialEraser::walkToExprPre(swift::Expr*) + 361
8 swift 0x00000001085b8ea5 (anonymous namespace)::Traversal::visit(swift::Expr*) + 4981
9 swift 0x00000001085b6f75 swift::Expr::walk(swift::ASTWalker&) + 53
10 swift 0x000000010842e375 (anonymous namespace)::FailureDiagnosis::typeCheckChildIndependently(swift::Expr*, swift::Type, swift::ContextualTypePurpose, swift::OptionSet<TCCFlags, unsigned int>, swift::ExprTypeCheckListener*) + 1221
11 swift 0x0000000108434ea3 (anonymous namespace)::FailureDiagnosis::typeCheckArgumentChildIndependently(swift::Expr*, swift::Type, (anonymous namespace)::CalleeCandidateInfo const&, swift::OptionSet<TCCFlags, unsigned int>) + 1987
12 swift 0x000000010843e9a1 (anonymous namespace)::FailureDiagnosis::visitApplyExpr(swift::ApplyExpr*) + 913
13 swift 0x0000000108428f6a swift::ASTVisitor<(anonymous namespace)::FailureDiagnosis, bool, void, void, void, void, void>::visit(swift::Expr*) + 170
14 swift 0x0000000108422888 swift::constraints::ConstraintSystem::diagnoseFailureForExpr(swift::Expr*) + 104
15 swift 0x00000001084289a8 swift::constraints::ConstraintSystem::salvage(llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::Expr*) + 4056
16 swift 0x00000001084ab665 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>) + 917
17 swift 0x00000001084b17d1 swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem*) + 625
18 swift 0x000000010852c061 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 545
19 swift 0x000000010852c543 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 1795
20 swift 0x000000010852bf8e swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 334
21 swift 0x000000010852b369 (anonymous namespace)::StmtChecker::typeCheckBody(swift::BraceStmt*&) + 25
22 swift 0x000000010852a63f swift::TypeChecker::typeCheckFunctionBodyUntil(swift::FuncDecl*, swift::SourceLoc) + 383
23 swift 0x000000010852a463 swift::TypeChecker::typeCheckAbstractFunctionBodyUntil(swift::AbstractFunctionDecl*, swift::SourceLoc) + 35
24 swift 0x000000010852afe4 swift::TypeChecker::typeCheckAbstractFunctionBody(swift::AbstractFunctionDecl*) + 180
25 swift 0x00000001084e5c56 typeCheckFunctionsAndExternalDecls(swift::TypeChecker&) + 166
26 swift 0x00000001084e68f0 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int) + 1568
27 swift 0x000000010818798c swift::CompilerInstance::performSema() + 3916
28 swift 0x0000000107c82ad1 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*) + 449
29 swift 0x0000000107c8163f swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2895
30 swift 0x0000000107c43ea0 main + 2448
31 libdyld.dylib 0x00007fffa5f16255 start + 1

The stack trace doesn’t really help tell me what’s going wrong; does anyone have the same issue or know why this is happening?

It’s a crash while trying to emit a diagnostic after failing to type check an expression. We often print the expression in question after the stack trace, so you might check to see if that is being emitted. It may help you find a work-around.

Thanks,
Saagar Jha

P.S. Should I file a bug on the JIRA?

Yes, please!

Any crash is worthy of a bug report on JIRA. We’ll need a test case along with instructions on how to reproduce the issue using that test case. Small, self-contained source files are always ideal, but an entire project works too if you cannot find a way to isolate it.

Mark

···

On Aug 4, 2016, at 8:51 PM, Saagar Jha via swift-users <swift-users@swift.org> wrote:

Thanks, I managed to create a small test project with the same issue; I’ve filed it as SR-2288 <https://bugs.swift.org/browse/SR-2288&gt;\.

Saagar Jha

···

On Aug 4, 2016, at 21:01, Mark Lacey <mark.lacey@apple.com> wrote:

On Aug 4, 2016, at 8:51 PM, Saagar Jha via swift-users <swift-users@swift.org <mailto:swift-users@swift.org>> wrote:

Hello Swift Users,

This afternoon I updated my Xcode to Xcode 8 beta 4, and tried to compile one of my previously migrated Swift 3 projects. Along with a couple of renames, the compiler kept crashing due to a segmentation fault. Since the issue appeared to be similar to SR-2227, which was supposedly fixed with a pull request a couple days ago, I downloaded today’s snapshot toolchain. The new toolchain throws an assertion:

Assertion failed: (value != OpenExistentials.end() && "didn't see this OVE in a containing OpenExistentialExpr?"), function walkToExprPre, file /Users/buildnode/jenkins/workspace/oss-swift-package-osx/swift/lib/Sema/CSDiag.cpp, line 3082.
0 swift 0x000000010a932ebb llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43
1 swift 0x000000010a932106 llvm::sys::RunSignalHandlers() + 70
2 swift 0x000000010a93360f SignalHandler(int) + 383
3 libsystem_platform.dylib 0x00007fffa6122d7a _sigtramp + 26
4 libsystem_platform.dylib 0x0000000100000001 _sigtramp + 1508758177
5 swift 0x000000010a93335e abort + 14
6 swift 0x000000010a933341 __assert_rtn + 81
7 swift 0x0000000108431879 eraseOpenedExistentials(swift::Expr*&)::ExistentialEraser::walkToExprPre(swift::Expr*) + 361
8 swift 0x00000001085b8ea5 (anonymous namespace)::Traversal::visit(swift::Expr*) + 4981
9 swift 0x00000001085b6f75 swift::Expr::walk(swift::ASTWalker&) + 53
10 swift 0x000000010842e375 (anonymous namespace)::FailureDiagnosis::typeCheckChildIndependently(swift::Expr*, swift::Type, swift::ContextualTypePurpose, swift::OptionSet<TCCFlags, unsigned int>, swift::ExprTypeCheckListener*) + 1221
11 swift 0x0000000108434ea3 (anonymous namespace)::FailureDiagnosis::typeCheckArgumentChildIndependently(swift::Expr*, swift::Type, (anonymous namespace)::CalleeCandidateInfo const&, swift::OptionSet<TCCFlags, unsigned int>) + 1987
12 swift 0x000000010843e9a1 (anonymous namespace)::FailureDiagnosis::visitApplyExpr(swift::ApplyExpr*) + 913
13 swift 0x0000000108428f6a swift::ASTVisitor<(anonymous namespace)::FailureDiagnosis, bool, void, void, void, void, void>::visit(swift::Expr*) + 170
14 swift 0x0000000108422888 swift::constraints::ConstraintSystem::diagnoseFailureForExpr(swift::Expr*) + 104
15 swift 0x00000001084289a8 swift::constraints::ConstraintSystem::salvage(llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::Expr*) + 4056
16 swift 0x00000001084ab665 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>) + 917
17 swift 0x00000001084b17d1 swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem*) + 625
18 swift 0x000000010852c061 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 545
19 swift 0x000000010852c543 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 1795
20 swift 0x000000010852bf8e swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 334
21 swift 0x000000010852b369 (anonymous namespace)::StmtChecker::typeCheckBody(swift::BraceStmt*&) + 25
22 swift 0x000000010852a63f swift::TypeChecker::typeCheckFunctionBodyUntil(swift::FuncDecl*, swift::SourceLoc) + 383
23 swift 0x000000010852a463 swift::TypeChecker::typeCheckAbstractFunctionBodyUntil(swift::AbstractFunctionDecl*, swift::SourceLoc) + 35
24 swift 0x000000010852afe4 swift::TypeChecker::typeCheckAbstractFunctionBody(swift::AbstractFunctionDecl*) + 180
25 swift 0x00000001084e5c56 typeCheckFunctionsAndExternalDecls(swift::TypeChecker&) + 166
26 swift 0x00000001084e68f0 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int) + 1568
27 swift 0x000000010818798c swift::CompilerInstance::performSema() + 3916
28 swift 0x0000000107c82ad1 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*) + 449
29 swift 0x0000000107c8163f swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2895
30 swift 0x0000000107c43ea0 main + 2448
31 libdyld.dylib 0x00007fffa5f16255 start + 1

The stack trace doesn’t really help tell me what’s going wrong; does anyone have the same issue or know why this is happening?

It’s a crash while trying to emit a diagnostic after failing to type check an expression. We often print the expression in question after the stack trace, so you might check to see if that is being emitted. It may help you find a work-around.

Thanks,
Saagar Jha

P.S. Should I file a bug on the JIRA?

Yes, please!

Any crash is worthy of a bug report on JIRA. We’ll need a test case along with instructions on how to reproduce the issue using that test case. Small, self-contained source files are always ideal, but an entire project works too if you cannot find a way to isolate it.

Mark