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-6388] Generic indirect enum triggers compiler crash crash #48938

Closed
swift-ci opened this issue Nov 15, 2017 · 2 comments
Closed

[SR-6388] Generic indirect enum triggers compiler crash crash #48938

swift-ci opened this issue Nov 15, 2017 · 2 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

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-6388
Radar rdar://problem/35561360
Original Reporter gmilos (JIRA User)
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

gmilos:/tmp/repro/sr/crash$

swift --version
Apple Swift version 4.1-dev (LLVM 23b3d8ddc9, Clang 7729192d63, Swift 7ba352c)

Target: x86_64-apple-darwin17.3.0

(i.e. swift-DEVELOPMENT-SNAPSHOT-2017-11-14-a)

Also reproduced with 4.0-RELEASE and 4.0.2-RELEASE

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

md5: 7e69bab553b138adf18aed2433dccfa4

Issue Description:

Generic version of the enum used to report SR-6381 causes a compiler crash, as follows:

gmilos:/tmp/repro/sr/crash$
swift build
Compile Swift Module 'ContextMemoryLeakRepro' (1 sources)
Assertion failed: ((options.contains(SubstFlags::AllowLoweredTypes) || !isa(type)) && "should not be doing AST type-substitution on a lowered SIL type;" "use SILType::subst"), function operator(), file /Users/buildnode/jenkins/workspace/oss-swift-package-osx/swift/lib/AST/Type.cpp, line 3209.
0 swift 0x000000011123fdb8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1 swift 0x000000011123ed06 llvm::sys::RunSignalHandlers() + 86
2 swift 0x000000011124037e SignalHandler(int) + 366
3 libsystem_platform.dylib 0x00007fff62206f5a _sigtramp + 26
4 libsystem_platform.dylib 0x00007ffee1e41297 _sigtramp + 2143527767
5 libsystem_c.dylib 0x00007fff62031312 abort + 127
6 libsystem_c.dylib 0x00007fff61ff9368 basename_r + 0
7 swift 0x000000010ef16c2c llvm::Optionalswift::Type llvm::function_ref<llvm::Optionalswift::Type (swift::TypeBase*)>::callback_fn<substType(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optionalswift::ProtocolConformanceRef (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::SubstOptions)::$_18>(long, swift::TypeBase*) + 2124
8 swift 0x000000010ef1318a swift::Type::transformRec(llvm::function_ref<llvm::Optionalswift::Type (swift::TypeBase*)>) const + 154
9 swift 0x000000010ef1351b swift::Type::transformRec(llvm::function_ref<llvm::Optionalswift::Type (swift::TypeBase*)>) const + 1067
10 swift 0x000000010ef13a3d swift::Type::transformRec(llvm::function_ref<llvm::Optionalswift::Type (swift::TypeBase*)>) const + 2381
11 swift 0x000000010ef13a3d swift::Type::transformRec(llvm::function_ref<llvm::Optionalswift::Type (swift::TypeBase*)>) const + 2381
12 swift 0x000000010ef11aa3 substType(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optionalswift::ProtocolConformanceRef (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::SubstOptions) + 211
13 swift 0x000000010ef11082 swift::Type::subst(llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optionalswift::ProtocolConformanceRef (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::SubstOptions) const + 130
14 swift 0x000000010ef04e93 swift::SubstitutionMap::subst(llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optionalswift::ProtocolConformanceRef (swift::CanType, swift::Type, swift::ProtocolType*)>) const + 323
15 swift 0x000000010ef164ba llvm::Optionalswift::Type llvm::function_ref<llvm::Optionalswift::Type (swift::TypeBase*)>::callback_fn<substType(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optionalswift::ProtocolConformanceRef (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::SubstOptions)::$_18>(long, swift::TypeBase*) + 218
16 swift 0x000000010ef1318a swift::Type::transformRec(llvm::function_ref<llvm::Optionalswift::Type (swift::TypeBase*)>) const + 154
17 swift 0x000000010ef11aa3 substType(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optionalswift::ProtocolConformanceRef (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::SubstOptions) + 211
18 swift 0x000000010ef11082 swift::Type::subst(llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optionalswift::ProtocolConformanceRef (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::SubstOptions) const + 130
19 swift 0x000000010df32ea5 swift::irgen::TypeConverter::getExemplarType(swift::CanType) + 133
20 swift 0x000000010df32a2b swift::irgen::TypeConverter::getTypeEntry(swift::CanType) + 395
21 swift 0x000000010df324ce swift::irgen::IRGenModule::getTypeInfo(swift::SILType) + 46
22 swift 0x000000010df3249c swift::irgen::IRGenFunction::getTypeInfo(swift::SILType) + 12
23 swift 0x000000010df6955e (anonymous namespace)::IRGenSILFunction::emitSILFunction() + 1102
24 swift 0x000000010df68c06 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 1382
25 swift 0x000000010de84972 swift::irgen::IRGenerator::emitGlobalTopLevel() + 450
26 swift 0x000000010df45127 performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, std::__1::unique_ptr<swift::SILModule, std::__1::default_deleteswift::SILModule >, llvm::StringRef, llvm::LLVMContext&, swift::SourceFile*, llvm::GlobalVariable**, unsigned int) + 1159
27 swift 0x000000010df457b6 swift::performIRGeneration(swift::IRGenOptions&, swift::SourceFile&, std::__1::unique_ptr<swift::SILModule, std::__1::default_deleteswift::SILModule >, llvm::StringRef, llvm::LLVMContext&, unsigned int, llvm::GlobalVariable**) + 86
28 swift 0x000000010ddffb27 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 13511
29 swift 0x000000010ddfb723 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3315
30 swift 0x000000010ddbbf60 main + 3360
31 libdyld.dylib 0x00007fff61f85115 start + 1
Stack dump:
0. Program arguments: /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2017-11-14-a.xctoolchain/usr/bin/swift -frontend -c -primary-file /private/tmp/repro/sr/crash/Sources/ContextMemoryLeakRepro/main.swift -target x86_64-apple-macosx10.10 -enable-objc-interop -sdk /Applications/Xcode.real.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -I /private/tmp/repro/sr/crash/.build/x86_64-apple-macosx10.10/debug -F /Applications/Xcode.real.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -enable-testing -g -module-cache-path /private/tmp/repro/sr/crash/.build/x86_64-apple-macosx10.10/debug/ModuleCache -swift-version 4 -Onone -D SWIFT_PACKAGE -emit-module-doc-path /private/tmp/repro/sr/crash/.build/x86_64-apple-macosx10.10/debug/ContextMemoryLeakRepro.build/mainpartial.swiftdoc -module-name ContextMemoryLeakRepro -emit-module-path /private/tmp/repro/sr/crash/.build/x86_64-apple-macosx10.10/debug/ContextMemoryLeakRepro.build/mainpartial.swiftmodule -emit-dependencies-path /private/tmp/repro/sr/crash/.build/x86_64-apple-macosx10.10/debug/ContextMemoryLeakRepro.build/main.d -emit-reference-dependencies-path /private/tmp/repro/sr/crash/.build/x86_64-apple-macosx10.10/debug/ContextMemoryLeakRepro.build/main.swiftdeps -num-threads 8 -o /private/tmp/repro/sr/crash/.build/x86_64-apple-macosx10.10/debug/ContextMemoryLeakRepro.build/main.swift.o

  1. While emitting IR SIL function "@_T022ContextMemoryLeakRepro4ListO4findxycSgSi3key_tF".
    for 'find(key:)' at /private/tmp/repro/sr/crash/Sources/ContextMemoryLeakRepro/main.swift:7:5
    :0: error: unable to execute command: Abort trap: 6
    :0: error: compile command failed due to signal 6 (use -v to see invocation)
    error: terminated(1): /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2017-11-14-a.xctoolchain/usr/bin/swift-build-tool -f /private/tmp/repro/sr/crash/.build/debug.yaml main

Attaching the sources in the tarball (again, same as SR-6381).

@belkadan
Copy link
Contributor

Reduced:

public enum List<V> {
    indirect case node(() -> V)
    case empty

    func find() -> (() -> V) {
        switch self {
        case .empty:
            fatalError()
        case .node(let head):
            return head
        }
    }
}

@swift-ci create

@aschwaighofer
Copy link
Member

Fixed by:
#14215
#14234

@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