-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
SILassertion failureBug → crash: An assertion failureBug → crash: An assertion failurebugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwareopaque result typesFeature → types → opaque types: opaque result typesFeature → types → opaque types: opaque result typesopaque typesFeature → types: opaque typesFeature → types: opaque typesverifier
Description
Description
https://ci-external.swift.org/job/swift-main-windows-toolchain/867/consoleText
Reproduction
A build failure on the CI.
Also, a reduced test:
% cat crasher.swift
struct A {}
protocol P {}
extension P {
func foo() -> some Sequence<A> {
EmptyCollection<A>()
}
}
struct B {
let p: P
func bar() {
for x in p.foo() {}
}
}
% ~/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-11-20-a.xctoolchain/usr/bin/swiftc -O ~/tmp/crasher.swift
error: compile command failed due to signal 6 (use -v to see invocation)
SIL verification failed: Should not have an operand for the opened existential: AMI->getTypeDependentOperands().empty()
Verifying instruction:
%4 = open_existential_addr immutable_access %3 : $*any P to $*@opened("FBD4C218-B28D-11EF-81E3-BAEE63F10E7B", any P) Self // users: %12, %8, %8, %7
-> %12 = witness_method $@_opaqueReturnTypeOf("$s7crasher1PPAAE3fooQryF", 0) __<@opened("FBD4C218-B28D-11EF-81E3-BAEE63F10E7B", any P) Self>, #Sequence.makeIterator : <Self where Self : Sequence> (__owned Self) -> () -> Self.Iterator, %4 : $*@opened("FBD4C218-B28D-11EF-81E3-BAEE63F10E7B", any P) Self : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (@in τ_0_0) -> @out τ_0_0.Iterator // type-defs: %4; user: %14
%14 = apply %12<@opened("FBD4C632-B28D-11EF-81E3-BAEE63F10E7B", any Sequence<A>) Self>(%13, %10) : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (@in τ_0_0) -> @out τ_0_0.Iterator // type-defs: %9
In function:
// B.bar()
// Isolation: unspecified
sil hidden @$s7crasher1BV3baryyF : $@convention(method) (@in_guaranteed B) -> () {
[%0: noescape **]
[global: read,write,copy,destroy,allocate,deinit_barrier]
// %0 "self" // users: %3, %1
bb0(%0 : $*B):
debug_value %0 : $*B, let, name "self", argno 1, expr op_deref // id: %1
%2 = alloc_stack [lexical] [var_decl] $any IteratorProtocol<A>, var, name "$x$generator", type $any IteratorProtocol<A> // users: %21, %29, %28, %13
%3 = struct_element_addr %0 : $*B, #B.p // user: %4
%4 = open_existential_addr immutable_access %3 : $*any P to $*@opened("FBD4C218-B28D-11EF-81E3-BAEE63F10E7B", any P) Self // users: %12, %8, %8, %7
%5 = alloc_stack $any Sequence<A> // users: %17, %16, %9, %7
// function_ref P.foo()
%6 = function_ref @$s7crasher1PPAAE3fooQryF : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> @out EmptyCollection<A> // user: %8
%7 = init_existential_addr %5 : $*any Sequence<A>, $@_opaqueReturnTypeOf("$s7crasher1PPAAE3fooQryF", 0) __<@opened("FBD4C218-B28D-11EF-81E3-BAEE63F10E7B", any P) Self> // type-defs: %4; user: %8
%8 = apply %6<@opened("FBD4C218-B28D-11EF-81E3-BAEE63F10E7B", any P) Self>(%7, %4) : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> @out EmptyCollection<A> // type-defs: %4
%9 = open_existential_addr immutable_access %5 : $*any Sequence<A> to $*@opened("FBD4C632-B28D-11EF-81E3-BAEE63F10E7B", any Sequence<A>) Self // users: %18, %14, %13, %11, %10
%10 = alloc_stack $@opened("FBD4C632-B28D-11EF-81E3-BAEE63F10E7B", any Sequence<A>) Self // type-defs: %9; users: %15, %14, %11
copy_addr %9 to [init] %10 : $*@opened("FBD4C632-B28D-11EF-81E3-BAEE63F10E7B", any Sequence<A>) Self // id: %11
%12 = witness_method $@_opaqueReturnTypeOf("$s7crasher1PPAAE3fooQryF", 0) __<@opened("FBD4C218-B28D-11EF-81E3-BAEE63F10E7B", any P) Self>, #Sequence.makeIterator : <Self where Self : Sequence> (__owned Self) -> () -> Self.Iterator, %4 : $*@opened("FBD4C218-B28D-11EF-81E3-BAEE63F10E7B", any P) Self : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (@in τ_0_0) -> @out τ_0_0.Iterator // type-defs: %4; user: %14
%13 = init_existential_addr %2 : $*any IteratorProtocol<A>, $@opened("FBD4C632-B28D-11EF-81E3-BAEE63F10E7B", any Sequence<A>) Self.Iterator // type-defs: %9; user: %14
%14 = apply %12<@opened("FBD4C632-B28D-11EF-81E3-BAEE63F10E7B", any Sequence<A>) Self>(%13, %10) : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (@in τ_0_0) -> @out τ_0_0.Iterator // type-defs: %9
dealloc_stack %10 : $*@opened("FBD4C632-B28D-11EF-81E3-BAEE63F10E7B", any Sequence<A>) Self // id: %15
destroy_addr %5 : $*any Sequence<A> // id: %16
dealloc_stack %5 : $*any Sequence<A> // id: %17
%18 = witness_method $@opened("FBD4C632-B28D-11EF-81E3-BAEE63F10E7B", any Sequence<A>) Self.Iterator, #IteratorProtocol.next : <Self where Self : IteratorProtocol> (inout Self) -> () -> Self.Element?, %9 : $*@opened("FBD4C632-B28D-11EF-81E3-BAEE63F10E7B", any Sequence<A>) Self : $@convention(witness_method: IteratorProtocol) <τ_0_0 where τ_0_0 : IteratorProtocol> (@inout τ_0_0) -> @out Optional<τ_0_0.Element> // type-defs: %9; user: %22
br bb1 // id: %19
bb1: // Preds: bb2 bb0
%20 = alloc_stack $Optional<A> // users: %23, %24, %22
%21 = open_existential_addr mutable_access %2 : $*any IteratorProtocol<A> to $*@opened("FBD4C9E8-B28D-11EF-81E3-BAEE63F10E7B", any IteratorProtocol<A>) Self // users: %22, %22
%22 = apply %18<@opened("FBD4C9E8-B28D-11EF-81E3-BAEE63F10E7B", any IteratorProtocol<A>) Self>(%20, %21) : $@convention(witness_method: IteratorProtocol) <τ_0_0 where τ_0_0 : IteratorProtocol> (@inout τ_0_0) -> @out Optional<τ_0_0.Element> // type-defs: %21
%23 = load %20 : $*Optional<A> // user: %25
dealloc_stack %20 : $*Optional<A> // id: %24
switch_enum %23 : $Optional<A>, case #Optional.some!enumelt: bb2, case #Optional.none!enumelt: bb3 // id: %25
bb2(%26 : $A): // Preds: bb1
br bb1 // id: %27
bb3: // Preds: bb1
destroy_addr %2 : $*any IteratorProtocol<A> // id: %28
dealloc_stack %2 : $*any IteratorProtocol<A> // id: %29
%30 = tuple () // user: %31
return %30 : $() // id: %31
} // end sil function '$s7crasher1BV3baryyF'
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0. Program arguments: /Users/hiroshi/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-11-20-a.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file /Users/hiroshi/tmp/crasher.swift -target arm64-apple-macosx14.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -color-diagnostics -O -empty-abi-descriptor -resource-dir /Users/hiroshi/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-11-20-a.xctoolchain/usr/lib/swift -module-name crasher -in-process-plugin-server-path /Users/hiroshi/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-11-20-a.xctoolchain/usr/lib/swift/host/libSwiftInProcPluginServer.dylib -plugin-path /Users/hiroshi/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-11-20-a.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Users/hiroshi/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-11-20-a.xctoolchain/usr/local/lib/swift/host/plugins -enable-default-cmo -o /var/folders/ww/kxcj3hm12kd92gcwr9t3y7k40000gq/T/TemporaryDirectory.WYwECW/crasher-1.o
1. Apple Swift version 6.1-dev (LLVM 0f86f354a7bc883, Swift d3064c5fc64ba06)
2. Compiling with effective version 5.10
3. While verifying SIL function "@$s7crasher1BV3baryyF".
for 'bar()' (at /Users/hiroshi/tmp/crasher.swift:12:5)
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0 swift-frontend 0x00000001063112e8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1 swift-frontend 0x000000010630f9cc llvm::sys::RunSignalHandlers() + 112
2 swift-frontend 0x0000000106311944 SignalHandler(int) + 304
3 libsystem_platform.dylib 0x000000018e1f6584 _sigtramp + 56
4 libsystem_pthread.dylib 0x000000018e1c5c20 pthread_kill + 288
5 libsystem_c.dylib 0x000000018e0d2a30 abort + 180
6 swift-frontend 0x000000010181d6f0 swift::SILModule::print(llvm::raw_ostream&, swift::ModuleDecl*, swift::SILOptions const&, bool) const + 0
7 swift-frontend 0x000000010183aa98 swift::SILVisitorBase<(anonymous namespace)::SILVerifier, void>::visitSILBasicBlock(swift::SILBasicBlock*) + 87712
8 swift-frontend 0x00000001018252f8 (anonymous namespace)::SILVerifier::visitSILBasicBlock(swift::SILBasicBlock*) + 28
9 swift-frontend 0x0000000101823a60 (anonymous namespace)::SILVerifier::visitSILFunction(swift::SILFunction*) + 10728
10 swift-frontend 0x000000010181d8a8 swift::SILFunction::verify(swift::CalleeCache*, bool, bool, bool) const + 224
11 swift-frontend 0x0000000101820600 swift::SILModule::verify(swift::CalleeCache*, bool, bool) const + 192
12 swift-frontend 0x00000001018204d8 swift::SILModule::verify(bool, bool) const + 140
13 swift-frontend 0x0000000100a51a04 swift::CompilerInstance::performSILProcessing(swift::SILModule*) + 580
14 swift-frontend 0x00000001007fe1d4 performCompileStepsPostSILGen(swift::CompilerInstance&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) + 820
15 swift-frontend 0x00000001007fd850 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 656
16 swift-frontend 0x0000000100809de8 withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 160
17 swift-frontend 0x00000001007ff72c performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 716
18 swift-frontend 0x00000001007fedf8 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2328
19 swift-frontend 0x00000001005d3490 swift::mainEntry(int, char const**) + 3100
20 dyld 0x000000018de3b154 start + 2476
hiroshi@himbp tmp %
Expected behavior
No crash
Environment
The CI https://ci-external.swift.org/job/swift-main-windows-toolchain.
Also the swift-DEVELOPMENT-SNAPSHOT-2024-11-20-a.xctoolchain
build from swift.org on macOS.
Additional information
No response
Metadata
Metadata
Assignees
Labels
SILassertion failureBug → crash: An assertion failureBug → crash: An assertion failurebugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwareopaque result typesFeature → types → opaque types: opaque result typesFeature → types → opaque types: opaque result typesopaque typesFeature → types: opaque typesFeature → types: opaque typesverifier