Skip to content

[SR-10015] values.map(Result.success) raises assertion failure #52418

@swift-ci

Description

@swift-ci
Previous ID SR-10015
Radar rdar://problem/49241923
Original Reporter mattgallagher (JIRA User)
Type Bug
Status Closed
Resolution Done
Environment

Apple Swift version 5.0-dev (LLVM 6ddb64316c, Swift e76b5a8)

Target: x86_64-apple-darwin18.2.0

macOS Mojave 10.14.3 18D109

MacBookPro15,1

Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug, CompilerCrash, NotOptimizedOnly
Assignee @slavapestov
Priority Medium

md5: a54e2570604c4689bc20a3a12390f449

is duplicated by:

  • SR-10093 Bugs around coercing errors
  • SR-10164 Compiler Crash: Result<T: Swift.Error>.success

Issue Description:

The following code:

import Swift
let x = ["a", "b"]
let results: [Result<String, Error>] = x.map(Result.success)
print(results) 

raises the following assertion:

$ /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2019-02-26-a.xctoolchain/usr/bin/swiftc test.swift 
Assertion failed: (isa<ArchetypeType>(type)), function addProtocolConformance, file /Users/buildnode/jenkins/workspace/oss-swift-package-osx/swift/lib/IRGen/GenProto.cpp, line 2718.
Stack dump:
0.  Program arguments: /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2019-02-26-a.xctoolchain/usr/bin/swift -frontend -c -primary-file test.swift -target x86_64-apple-darwin18.2.0 -enable-objc-interop -color-diagnostics -module-name test -o /var/folders/8k/wsn38m712j9fwys6_m92b01w0000gn/T/test-05a7eb.o 
1.  While emitting IR SIL function "@main".
0  swift                    0x000000010588c815 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swift                    0x000000010588bad5 llvm::sys::RunSignalHandlers() + 85
2  swift                    0x000000010588cdf8 SignalHandler(int) + 264
3  libsystem_platform.dylib 0x00007fff71d47b3d _sigtramp + 29
4  swift                    0x0000000106ad4280 cmark_strbuf__initbuf + 127627
5  libsystem_c.dylib        0x00007fff71c051c9 abort + 127
6  libsystem_c.dylib        0x00007fff71bcd868 basename_r + 0
7  swift                    0x0000000101f84dae swift::irgen::NecessaryBindings::addProtocolConformance(swift::CanType, swift::ProtocolConformanceRef) + 238
8  swift                    0x0000000101f8c7da void llvm::function_ref<void (swift::irgen::GenericRequirement)>::callback_fn<swift::irgen::NecessaryBindings::forFunctionInvocations(swift::irgen::IRGenModule&, swift::CanTypeWrapper<swift::SILFunctionType>, swift::SubstitutionMap)::$_6>(long, swift::irgen::GenericRequirement) + 154
9  swift                    0x0000000101f8ae51 void llvm::function_ref<void (swift::irgen::GenericRequirement)>::callback_fn<(anonymous namespace)::PolymorphicConvention::enumerateUnfulfilledRequirements(llvm::function_ref<void (swift::irgen::GenericRequirement)> const&)::$_12>(long, swift::irgen::GenericRequirement) + 161
10 swift                    0x0000000101f7dbb9 swift::irgen::enumerateGenericSignatureRequirements(swift::CanGenericSignature, llvm::function_ref<void (swift::irgen::GenericRequirement)> const&) + 281
11 swift                    0x0000000101f853fe swift::irgen::NecessaryBindings::forFunctionInvocations(swift::irgen::IRGenModule&, swift::CanTypeWrapper<swift::SILFunctionType>, swift::SubstitutionMap) + 238
12 swift                    0x0000000101f3b99b swift::irgen::emitFunctionPartialApplication(swift::irgen::IRGenFunction&, swift::SILFunction&, swift::irgen::FunctionPointer const&, llvm::Value*, swift::irgen::Explosion&, llvm::ArrayRef<swift::SILParameterInfo>, swift::SubstitutionMap, swift::CanTypeWrapper<swift::SILFunctionType>, swift::CanTypeWrapper<swift::SILFunctionType>, swift::CanTypeWrapper<swift::SILFunctionType>, swift::irgen::Explosion&, bool) + 139
13 swift                    0x0000000101ff4a2d swift::SILInstructionVisitor<(anonymous namespace)::IRGenSILFunction, void>::visit(swift::SILInstruction*) + 48141
14 swift                    0x0000000101fe5533 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 8131
15 swift                    0x0000000101ef060e swift::irgen::IRGenerator::emitGlobalTopLevel() + 734
16 swift                    0x0000000101fbf77e performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::LLVMContext&, swift::SourceFile*, llvm::GlobalVariable**) + 1150
17 swift                    0x0000000101fbfcc6 swift::performIRGeneration(swift::IRGenOptions&, swift::SourceFile&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::LLVMContext&, llvm::GlobalVariable**) + 86
18 swift                    0x0000000101e567be performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 14750
19 swift                    0x0000000101e520d5 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2997
20 swift                    0x0000000101df9042 main + 690
21 libdyld.dylib            0x00007fff71b5ced9 start + 1
<unknown>:0: error: unable to execute command: Abort trap: 6
<unknown>:0: error: compile command failed due to signal 6 (use -v to see invocation)

This assertion is not raised when optimization `-O` is passed to swiftc (in this case, the code compiles and runs as expected).

This problem occurs in the latest (Feb 26) Trunk Development (master) build and also in Xcode 10.2 beta 3.

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwarenon-optimized onlyFlag: An issue whose reproduction requires non-optimized compilation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions