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-6446] crash on synthesized initializer for private variable #48996

Closed
tayloraswift opened this issue Nov 21, 2017 · 3 comments
Closed

[SR-6446] crash on synthesized initializer for private variable #48996

tayloraswift opened this issue Nov 21, 2017 · 3 comments
Assignees
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 type checker Area → compiler: Semantic analysis

Comments

@tayloraswift
Copy link
Contributor

Previous ID SR-6446
Radar rdar://problem/35699666
Original Reporter @Kelvin13
Type Bug
Status Resolved
Resolution Done
Environment

Swift version 4.0.2 (swift-4.0.2-RELEASE)
Target: x86_64-unknown-linux-gnu

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash, TypeChecker
Assignee @Kelvin13
Priority Medium

md5: b054e940ebdc5911467158a849d036e4

Issue Description:

The following code causes a type checker crash.

struct A<T>
{
    private
    var b:[T]
}

func f(v:[Int])
{
    let u = A(b: v.sorted{ $0 < $1 }.map{ $0 })
}
@belkadan
Copy link
Contributor

   Assertion failed: (DC == closure->getParent() && "Decl context isn't correct"), function walkToClosureExprPre, file /Volumes/Data/swift-public/swift/lib/Sema/TypeCheckConstraints.cpp, line 1048.
0  swift                    0x00000001105f89b8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x00000001105f7906 llvm::sys::RunSignalHandlers() + 86
2  swift                    0x00000001105f8f7e SignalHandler(int) + 366
3  libsystem_platform.dylib 0x00007fff709b7f5a _sigtramp + 26
4  libsystem_platform.dylib 0x00007f83c40876b0 _sigtramp + 1399650160
5  libsystem_c.dylib        0x00007fff707e2312 abort + 127
6  libsystem_c.dylib        0x00007fff707aa368 basename_r + 0
7  swift                    0x000000010e0262ec (anonymous namespace)::PreCheckExpression::walkToExprPre(swift::Expr*) + 828
8  swift                    0x000000010e2e9f1a swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Expr*) + 8250
9  swift                    0x000000010e2ebf13 (anonymous namespace)::Traversal::visitApplyExpr(swift::ApplyExpr*) + 211
10 swift                    0x000000010e2e8d31 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Expr*) + 3665
11 swift                    0x000000010e2e71b4 swift::Expr::walk(swift::ASTWalker&) + 84
12 swift                    0x000000010e01a48e swift::TypeChecker::preCheckExpression(swift::Expr*&, swift::DeclContext*) + 158
13 swift                    0x000000010e01d813 swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem*) + 115
14 swift                    0x000000010df41683 (anonymous namespace)::FailureDiagnosis::typeCheckChildIndependently(swift::Expr*, swift::Type, swift::ContextualTypePurpose, swift::OptionSet<TCCFlags, unsigned int>, swift::ExprTypeCheckListener*, bool) + 1283
15 swift                    0x000000010df56e4a std::__1::__function::__func<(anonymous namespace)::FailureDiagnosis::diagnoseTrailingClosureErrors(swift::ApplyExpr*)::$_2, std::__1::allocator<(anonymous namespace)::FailureDiagnosis::diagnoseTrailingClosureErrors(swift::ApplyExpr*)::$_2>, bool (swift::Type, swift::Type)>::operator()(swift::Type&&, swift::Type&&) + 282
16 swift                    0x000000010df511a0 (anonymous namespace)::FailureDiagnosis::diagnoseClosureExpr(swift::ClosureExpr*, swift::Type, std::__1::function<bool (swift::Type, swift::Type)>) + 1424
17 swift                    0x000000010df52f51 (anonymous namespace)::FailureDiagnosis::visitApplyExpr(swift::ApplyExpr*) + 881
18 swift                    0x000000010df371b3 swift::constraints::ConstraintSystem::diagnoseFailureForExpr(swift::Expr*) + 83
19 swift                    0x000000010df3c492 swift::constraints::ConstraintSystem::salvage(llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::Expr*) + 3986
20 swift                    0x000000010e01a6e8 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>) + 120
21 swift                    0x000000010e01da46 swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem*) + 678
22 swift                    0x000000010df41683 (anonymous namespace)::FailureDiagnosis::typeCheckChildIndependently(swift::Expr*, swift::Type, swift::ContextualTypePurpose, swift::OptionSet<TCCFlags, unsigned int>, swift::ExprTypeCheckListener*, bool) + 1283
23 swift                    0x000000010df47cb6 (anonymous namespace)::FailureDiagnosis::typeCheckArgumentChildIndependently(swift::Expr*, swift::Type, swift::CalleeCandidateInfo const&, swift::OptionSet<TCCFlags, unsigned int>) + 2374
24 swift                    0x000000010df5410f (anonymous namespace)::FailureDiagnosis::visitApplyExpr(swift::ApplyExpr*) + 5423
25 swift                    0x000000010df371b3 swift::constraints::ConstraintSystem::diagnoseFailureForExpr(swift::Expr*) + 83
26 swift                    0x000000010df3c492 swift::constraints::ConstraintSystem::salvage(llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::Expr*) + 3986
27 swift                    0x000000010e01a6e8 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>) + 120
28 swift                    0x000000010e01da46 swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem*) + 678
29 swift                    0x000000010e02196d swift::TypeChecker::typeCheckBinding(swift::Pattern*&, swift::Expr*&, swift::DeclContext*, bool) + 429
30 swift                    0x000000010e021c97 swift::TypeChecker::typeCheckPatternBinding(swift::PatternBindingDecl*, unsigned int, bool) + 263
31 swift                    0x000000010e03a3e8 validatePatternBindingEntries(swift::TypeChecker&, swift::PatternBindingDecl*) + 856
32 swift                    0x000000010e034da5 (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 357
33 swift                    0x000000010e034c34 swift::TypeChecker::typeCheckDecl(swift::Decl*, bool) + 100
34 swift                    0x000000010e0a2aec swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 444
35 swift                    0x000000010e0a1e1b (anonymous namespace)::StmtChecker::typeCheckBody(swift::BraceStmt*&) + 27
36 swift                    0x000000010e0a1139 swift::TypeChecker::typeCheckFunctionBodyUntil(swift::FuncDecl*, swift::SourceLoc) + 233
37 swift                    0x000000010e0a1adb swift::TypeChecker::typeCheckAbstractFunctionBody(swift::AbstractFunctionDecl*) + 251
38 swift                    0x000000010e0c1daa typeCheckFunctionsAndExternalDecls(swift::TypeChecker&) + 186
39 swift                    0x000000010e0c2a2e swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int) + 1710
40 swift                    0x000000010dd55a43 swift::CompilerInstance::parseAndTypeCheckMainFile(swift::PersistentParserState&, swift::DelayedParsingCallbacks*, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>) + 435
41 swift                    0x000000010dd5491e swift::CompilerInstance::parseAndCheckTypes(swift::CompilerInstance::ImplicitImports const&) + 702
42 swift                    0x000000010dd540e8 swift::CompilerInstance::performSema() + 520
43 swift                    0x000000010d2ab455 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 1781
44 swift                    0x000000010d2a9e2a swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3290
45 swift                    0x000000010d26a680 main + 3328
46 libdyld.dylib            0x00007fff70736115 start + 1
47 libdyld.dylib            0x000000000000000a start + 2408357622
Stack dump:
0.  Program arguments: /Volumes/Data/swift-public/build/ninja/swift-macosx-x86_64/bin/swift -frontend -interpret - -enable-objc-interop -sdk /Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -color-diagnostics -module-name main 
1.  While type-checking 'f(v:)' at <stdin>:7:1
2.  While type-checking declaration 0x7f83c40790b0 at <stdin>:9:5
3.  While type-checking expression at [<stdin>:9:13 - line:9:47] RangeText="A(b: v.sorted{ $0 < $1 }.map{ $0 })"
4.  While type-checking expression at [<stdin>:9:18 - line:9:46] RangeText="v.sorted{ $0 < $1 }.map{ $0 }"
5.  While type-checking expression at [<stdin>:9:18 - line:9:38] RangeText="v.sorted{ $0 < $1 }.m"

@swift-ci create

@xedin
Copy link
Member

xedin commented Nov 28, 2017

@Kelvin13 The actual problem here is that variable is marked private so initializer for it is going to be private as well, I'm working on fixing the actual crash.

@xedin
Copy link
Member

xedin commented Nov 29, 2017

Fixed by #13115 and should be available in next nightly build. @Kelvin13 Please verify when the nightly becomes available and resolve. Thank you for reporting this!

@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
This issue was closed.
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 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

4 participants