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-206] Crash with print following non-mutated var #42828

Closed
ddunbar opened this issue Dec 12, 2015 · 4 comments
Closed

[SR-206] Crash with print following non-mutated var #42828

ddunbar opened this issue Dec 12, 2015 · 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

Comments

@ddunbar
Copy link
Member

ddunbar commented Dec 12, 2015

Previous ID SR-206
Radar None
Original Reporter @ddunbar
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash
Assignee cwillmore (JIRA)
Priority Medium

md5: df5ffa6cf55b8faabba3c5c61a6b0467

Issue Description:

This code crashes the swift compiler:

$ cat t.swift
private func f0(a: [Int]) {
    var i = 0
    print((i, a.count))
}

$ swift --version
Apple Swift version 2.2-dev (LLVM 46be9ff861, Clang 4deb154edc, Swift 778f82939c)
Target: x86_64-apple-macosx10.9
$ swiftc -c t.swift
t.swift:2:9: warning: variable 'i' was never mutated; consider changing to 'let' constant
    var i = 0
    ~~~ ^
    let
0  swift                    0x000000010a4e647b llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43
1  swift                    0x000000010a4e5916 llvm::sys::RunSignalHandlers() + 70
2  swift                    0x000000010a4e6aa3 SignalHandler(int) + 243
3  libsystem_platform.dylib 0x00007fff88854eaa _sigtramp + 26
4  libsystem_platform.dylib 0x00007f97dc04ce50 _sigtramp + 1400864704
5  swift                    0x00000001089eb819 swift::NominalTypeDecl::getMembers(bool) const + 41
6  swift                    0x0000000108470b44 (anonymous namespace)::LowerType::visitAnyStructType(swift::CanType, swift::StructDecl*) + 52
7  swift                    0x000000010846c18e swift::Lowering::TypeConverter::getTypeLoweringForUncachedLoweredType(swift::Lowering::TypeConverter::TypeKey) + 190
8  swift                    0x000000010846b5b3 swift::Lowering::TypeConverter::getTypeLowering(swift::Lowering::AbstractionPattern, swift::Type, unsigned int) + 2899
9  swift                    0x000000010846b273 swift::Lowering::TypeConverter::getTypeLowering(swift::Lowering::AbstractionPattern, swift::Type, unsigned int) + 2067
10 swift                    0x00000001084d01e9 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 18441
11 swift                    0x00000001084cbbb9 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 473
12 swift                    0x00000001084c8047 swift::Lowering::SILGenFunction::emitExprInto(swift::Expr*, swift::Lowering::Initialization*) + 279
13 swift                    0x00000001084a82ae (anonymous namespace)::ArgEmitter::emit(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 1950
14 swift                    0x00000001084a97dd (anonymous namespace)::ArgEmitter::emitShuffle(swift::Expr*, swift::Expr*, llvm::ArrayRef<swift::TupleTypeElt>, swift::ConcreteDeclRef, llvm::ArrayRef<swift::Expr*>, llvm::ArrayRef<int>, llvm::ArrayRef<unsigned int>, swift::Type, swift::Lowering::AbstractionPattern) + 2429
15 swift                    0x00000001084a8dd5 (anonymous namespace)::ArgEmitter::emitExpanded(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 1701
16 swift                    0x00000001084a8689 (anonymous namespace)::ArgEmitter::emit(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 2937
17 swift                    0x00000001084a755b (anonymous namespace)::CallSite::emit(swift::Lowering::SILGenFunction&, swift::Lowering::AbstractionPattern, (anonymous namespace)::ParamLowering&, llvm::SmallVectorImpl<swift::Lowering::ManagedValue>&, llvm::SmallVectorImpl<std::__1::pair<swift::Lowering::LValue, swift::SILLocation> >&, llvm::Optional<swift::ForeignErrorConvention> const&) && + 315
18 swift                    0x000000010849c0ba (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) + 2698
19 swift                    0x000000010849ae0a swift::Lowering::SILGenFunction::emitApplyExpr(swift::Expr*, swift::Lowering::SGFContext) + 58
20 swift                    0x00000001084cbae8 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 264
21 swift                    0x00000001084cac96 swift::Lowering::SILGenFunction::emitIgnoredExpr(swift::Expr*) + 486
22 swift                    0x000000010850a233 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 355
23 swift                    0x000000010850a0c5 swift::Lowering::SILGenFunction::emitStmt(swift::Stmt*) + 21
24 swift                    0x00000001084da450 swift::Lowering::SILGenFunction::emitFunction(swift::FuncDecl*) + 336
25 swift                    0x00000001084907b2 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 482
26 swift                    0x0000000108497040 swift::ASTVisitor<swift::Lowering::SILGenModule, void, void, void, void, void, void>::visit(swift::Decl*) + 272
27 swift                    0x000000010849441b swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) + 827
28 swift                    0x0000000108494ee0 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool, bool) + 928
29 swift                    0x000000010849528d swift::performSILGeneration(swift::FileUnit&, swift::SILOptions&, llvm::Optional<unsigned int>, bool) + 109
30 swift                    0x00000001082d746d performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&) + 11645
31 swift                    0x00000001082d44e3 frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 2691
32 swift                    0x00000001082d0285 main + 2821
33 libdyld.dylib            0x00007fff878575ad start + 1
34 libdyld.dylib            0x000000000000000c start + 2021296736
Stack dump:
0.  Program arguments: /Library/Developer/Toolchains/swift-2.2-SNAPSHOT-2015-12-01-a.xctoolchain/usr/bin/swift -frontend -c -primary-file t.swift -target x86_64-apple-macosx10.9 -enable-objc-interop -module-name t -o t.o 
1.  While emitting SIL for 'f0' at t.swift:1:9
Segmentation fault: 11
@ddunbar
Copy link
Member Author

ddunbar commented Dec 12, 2015

/cc @jckarter

@jckarter
Copy link
Member

These are usually Sema bugs due to the type-checker misassigning the parameters to `print` in one way or another. Giving to ChrisW since his work on cleaning up function types should clear up the problems here (and he likely has a dup).

@Dante-Broggi
Copy link
Contributor

I believe this has been fixed. If so, it should be closed.

@Dante-Broggi
Copy link
Contributor

Resolving as the provided code does not crash for me, and no one has responded since I asked.

@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
Projects
None yet
Development

No branches or pull requests

4 participants