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-8064] Compiler crash near nested withoutActuallyEscaping calls #50597

Closed
swift-ci opened this issue Jun 21, 2018 · 2 comments
Closed

[SR-8064] Compiler crash near nested withoutActuallyEscaping calls #50597

swift-ci opened this issue Jun 21, 2018 · 2 comments

Comments

@swift-ci
Copy link
Collaborator

@swift-ci swift-ci commented Jun 21, 2018

Previous ID SR-8064
Radar rdar://problem/41331672
Original Reporter neightchan (JIRA User)
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash, SILGen
Assignee @aschwaighofer
Priority Medium

md5: 0b6d7b9fe239e6b70b684a4cf9cd02a8

Issue Description:

The following code

import Foundation

struct Object {

    private func _doResize<Location>(
        includeHeader: (Int, Location) -> Bool,
        includeCell: (IndexPath, Location) -> Bool,
        includeFooter: (Int, Location) -> Bool
    )
    {
        withoutActuallyEscaping(includeHeader) { includeHeader in
            __doResize1(
                includeHeader: includeHeader,
                includeCell: includeCell,
                includeFooter: includeFooter
            )
        }
    }
    
    private func __doResize1<Location>(
        includeHeader: @escaping (Int, Location) -> Bool,
        includeCell: (IndexPath, Location) -> Bool,
        includeFooter: (Int, Location) -> Bool
    )
    {
        withoutActuallyEscaping(includeCell) { includeCell in
            __doResize2(
                includeHeader: includeHeader,
                includeCell: includeCell,
                includeFooter: includeFooter
            )
        }
    }
    
    private func __doResize2<Location>(
        includeHeader: @escaping (Int, Location) -> Bool,
        includeCell: @escaping (IndexPath, Location) -> Bool,
        includeFooter: (Int, Location) -> Bool
    )
    {
        withoutActuallyEscaping(includeFooter) { includeFooter in
        }
    }

}

results in the following output:

TYPE MISMATCH IN ARGUMENT 0 OF APPLY AT expression at [/.../path/to/main.swift:49:48 - line:49:9] RangeText=""
  argument value:   %11 = begin_borrow %10 : $@callee_guaranteed (Int, @in_guaranteed Location) -> Bool
  parameter type: $@callee_guaranteed (Int, @in_guaranteed Location) -> Bool
0  swift                    0x000000011117ae98 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x000000011117a0d7 llvm::sys::RunSignalHandlers() + 39
2  swift                    0x000000011117b512 SignalHandler(int) + 258
3  libsystem_platform.dylib 0x00007fff60a24f5a _sigtramp + 26
4  libsystem_platform.dylib 0x0000000116364558 _sigtramp + 3046372888
5  libsystem_c.dylib        0x00007fff607c21ae abort + 127
6  swift                    0x000000010e0a2672 swift::Lowering::SILGenFunction::emitApply(std::__1::unique_ptr<swift::Lowering::ResultPlan, std::__1::default_delete<swift::Lowering::ResultPlan> >&&, swift::Lowering::ArgumentScope&&, swift::SILLocation, swift::Lowering::ManagedValue, llvm::ArrayRef<swift::Substitution>, llvm::ArrayRef<swift::Lowering::ManagedValue>, swift::Lowering::CalleeTypeInfo const&, swift::Lowering::ApplyOptions, swift::Lowering::SGFContext) + 4226
7  swift                    0x000000010e0a5265 (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) + 3925
8  swift                    0x000000010e0a41e5 swift::Lowering::SILGenFunction::emitApplyExpr(swift::Expr*, swift::Lowering::SGFContext) + 1477
9  swift                    0x000000010e108b42 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 82
10 swift                    0x000000010e10cff0 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 17664
11 swift                    0x000000010e0fec21 swift::Lowering::SILGenFunction::emitIgnoredExpr(swift::Expr*) + 1217
12 swift                    0x000000010e167a33 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 8547
13 swift                    0x000000010e1658c5 swift::Lowering::SILGenFunction::emitStmt(swift::Stmt*) + 21
14 swift                    0x000000010e1204d6 swift::Lowering::SILGenFunction::emitFunction(swift::FuncDecl*) + 502
15 swift                    0x000000010e09f1ae swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*)::$_1::operator()(swift::SILFunction*) const + 302
16 swift                    0x000000010e096c36 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 774
17 swift                    0x000000010e170fb5 (anonymous namespace)::SILGenType::visitFuncDecl(swift::FuncDecl*) + 21
18 swift                    0x000000010e16f503 (anonymous namespace)::SILGenType::emitType() + 163
19 swift                    0x000000010e16f459 swift::Lowering::SILGenModule::visitNominalTypeDecl(swift::NominalTypeDecl*) + 25
20 swift                    0x000000010e09bc9b swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) + 795
21 swift                    0x000000010e09ca18 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool) + 344
22 swift                    0x000000010e09d01f swift::performSILGeneration(swift::FileUnit&, swift::SILOptions&, llvm::Optional<unsigned int>) + 95
23 swift                    0x000000010d96b22f performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 8655
24 swift                    0x000000010d968042 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2962
25 swift                    0x000000010d92397e main + 2334
26 libdyld.dylib            0x00007fff60716015 start + 1
Stack dump:
0.  Program arguments: /.../path/to/Developer/Toolchains/swift-4.2-DEVELOPMENT-SNAPSHOT-2018-06-20-a.xctoolchain/usr/bin/swift -frontend -c -primary-file /Users/nchandle/PermanentScratchpads/Ios/PermanentScratchpadIosCommandSwift42/PermanentScratchpadIosCommandSwift42/main.swift -emit-module-path /.../path/to/Developer/Xcode/DerivedData/PermanentScratchpadIosCommandSwift42-cpfmwymareqeysbckxhbkgeagfeu/Build/Intermediates.noindex/PermanentScratchpadIosCommandSwift42.build/Debug-iphonesimulator/PermanentScratchpadIosCommandSwift42.build/Objects-normal/x86_64/main~partial.swiftmodule -emit-module-doc-path /.../path/to/Developer/Xcode/DerivedData/PermanentScratchpadIosCommandSwift42-cpfmwymareqeysbckxhbkgeagfeu/Build/Intermediates.noindex/PermanentScratchpadIosCommandSwift42.build/Debug-iphonesimulator/PermanentScratchpadIosCommandSwift42.build/Objects-normal/x86_64/main~partial.swiftdoc -serialize-diagnostics-path /.../path/to/Developer/Xcode/DerivedData/PermanentScratchpadIosCommandSwift42-cpfmwymareqeysbckxhbkgeagfeu/Build/Intermediates.noindex/PermanentScratchpadIosCommandSwift42.build/Debug-iphonesimulator/PermanentScratchpadIosCommandSwift42.build/Objects-normal/x86_64/main.dia -emit-dependencies-path /.../path/to/Developer/Xcode/DerivedData/PermanentScratchpadIosCommandSwift42-cpfmwymareqeysbckxhbkgeagfeu/Build/Intermediates.noindex/PermanentScratchpadIosCommandSwift42.build/Debug-iphonesimulator/PermanentScratchpadIosCommandSwift42.build/Objects-normal/x86_64/main.d -emit-reference-dependencies-path /.../path/to/Developer/Xcode/DerivedData/PermanentScratchpadIosCommandSwift42-cpfmwymareqeysbckxhbkgeagfeu/Build/Intermediates.noindex/PermanentScratchpadIosCommandSwift42.build/Debug-iphonesimulator/PermanentScratchpadIosCommandSwift42.build/Objects-normal/x86_64/main.swiftdeps -target x86_64-apple-ios12.0-simulator -enable-objc-interop -sdk /Applications/Xcode-10b1.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.0.sdk -I /.../path/to/Developer/Xcode/DerivedData/PermanentScratchpadIosCommandSwift42-cpfmwymareqeysbckxhbkgeagfeu/Build/Products/Debug-iphonesimulator -F /.../path/to/Developer/Xcode/DerivedData/PermanentScratchpadIosCommandSwift42-cpfmwymareqeysbckxhbkgeagfeu/Build/Products/Debug-iphonesimulator -enable-testing -g -module-cache-path /.../path/to/Developer/Xcode/DerivedData/ModuleCache.noindex -swift-version 4.2 -enforce-exclusivity=checked -Onone -D DEBUG -serialize-debugging-options -Xcc -I/.../path/to/Developer/Xcode/DerivedData/PermanentScratchpadIosCommandSwift42-cpfmwymareqeysbckxhbkgeagfeu/Build/Intermediates.noindex/PermanentScratchpadIosCommandSwift42.build/Debug-iphonesimulator/PermanentScratchpadIosCommandSwift42.build/swift-overrides.hmap -Xcc -iquote -Xcc /.../path/to/Developer/Xcode/DerivedData/PermanentScratchpadIosCommandSwift42-cpfmwymareqeysbckxhbkgeagfeu/Build/Intermediates.noindex/PermanentScratchpadIosCommandSwift42.build/Debug-iphonesimulator/PermanentScratchpadIosCommandSwift42.build/PermanentScratchpadIosCommandSwift42-generated-files.hmap -Xcc -I/.../path/to/Developer/Xcode/DerivedData/PermanentScratchpadIosCommandSwift42-cpfmwymareqeysbckxhbkgeagfeu/Build/Intermediates.noindex/PermanentScratchpadIosCommandSwift42.build/Debug-iphonesimulator/PermanentScratchpadIosCommandSwift42.build/PermanentScratchpadIosCommandSwift42-own-target-headers.hmap -Xcc -I/.../path/to/Developer/Xcode/DerivedData/PermanentScratchpadIosCommandSwift42-cpfmwymareqeysbckxhbkgeagfeu/Build/Intermediates.noindex/PermanentScratchpadIosCommandSwift42.build/Debug-iphonesimulator/PermanentScratchpadIosCommandSwift42.build/PermanentScratchpadIosCommandSwift42-all-target-headers.hmap -Xcc -iquote -Xcc /.../path/to/Developer/Xcode/DerivedData/PermanentScratchpadIosCommandSwift42-cpfmwymareqeysbckxhbkgeagfeu/Build/Intermediates.noindex/PermanentScratchpadIosCommandSwift42.build/Debug-iphonesimulator/PermanentScratchpadIosCommandSwift42.build/PermanentScratchpadIosCommandSwift42-project-headers.hmap -Xcc -I/.../path/to/Developer/Xcode/DerivedData/PermanentScratchpadIosCommandSwift42-cpfmwymareqeysbckxhbkgeagfeu/Build/Products/Debug-iphonesimulator/include -Xcc -I/.../path/to/Developer/Xcode/DerivedData/PermanentScratchpadIosCommandSwift42-cpfmwymareqeysbckxhbkgeagfeu/Build/Intermediates.noindex/PermanentScratchpadIosCommandSwift42.build/Debug-iphonesimulator/PermanentScratchpadIosCommandSwift42.build/DerivedSources/x86_64 -Xcc -I/.../path/to/Developer/Xcode/DerivedData/PermanentScratchpadIosCommandSwift42-cpfmwymareqeysbckxhbkgeagfeu/Build/Intermediates.noindex/PermanentScratchpadIosCommandSwift42.build/Debug-iphonesimulator/PermanentScratchpadIosCommandSwift42.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -working-directory/Users/nchandle/PermanentScratchpads/Ios/PermanentScratchpadIosCommandSwift42 -module-name PermanentScratchpadIosCommandSwift42 -o /.../path/to/Developer/Xcode/DerivedData/PermanentScratchpadIosCommandSwift42-cpfmwymareqeysbckxhbkgeagfeu/Build/Intermediates.noindex/PermanentScratchpadIosCommandSwift42.build/Debug-iphonesimulator/PermanentScratchpadIosCommandSwift42.build/Objects-normal/x86_64/main.o -index-store-path /.../path/to/Developer/Xcode/DerivedData/PermanentScratchpadIosCommandSwift42-cpfmwymareqeysbckxhbkgeagfeu/Index/DataStore -index-system-modules 
1.  While emitting SIL for '__doResize2(includeHeader:includeCell:includeFooter:)' at /Users/nchandle/PermanentScratchpads/Ios/PermanentScratchpadIosCommandSwift42/PermanentScratchpadIosCommandSwift42/main.swift:43:13
2.  While silgen emitFunction SIL function "@$S36PermanentScratchpadIosCommandSwift426ObjectV11__doResize233_3C0D622B1BD357A7C824B380596E261ALL13includeHeader0Q4Cell0Q6FooterySbSi_xtc_Sb10Foundation9IndexPathV_xtcSbSi_xtXEtlF".
 for '__doResize2(includeHeader:includeCell:includeFooter:)' at /Users/nchandle/PermanentScratchpads/Ios/PermanentScratchpadIosCommandSwift42/PermanentScratchpadIosCommandSwift42/main.swift:43:13
error: Abort trap: 6
@belkadan
Copy link
Contributor

@belkadan belkadan commented Jun 21, 2018

@swift-ci create

@aschwaighofer
Copy link
Member

@aschwaighofer aschwaighofer commented Jun 22, 2018

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants