Skip to content

SIL verification failed: a destructure of a move-only-type-with-deinit requires a drop_deinit #85521

@kateinoigakukun

Description

@kateinoigakukun

Description

We found the crash in the swift-foundation build swiftlang/swift-foundation#1600

Reproduction

precedencegroup AssignmentPrecedence {
  assignment: true
}

@_marker public protocol Copyable {}

final class ProgressManager {}
struct S1 {}

public struct Subprogress: ~Copyable {
    internal var parent = ProgressManager()
    internal var isInitializedToProgressReporter: S1 = S1()

    public consuming func start() {
        isInitializedToProgressReporter = S1()
    }

    deinit {}
}
swift-frontend -frontend -c Check.swift -target wasm32-unknown-none -module-name Swift -parse-as-library -emit-sil -O -parse-stdlib

Stack dump

SIL verification failed: a destructure of a move-only-type-with-deinit requires a drop_deinit: isa<DropDeinitInst>(lookThroughOwnershipInsts(DSI->getOperand()))
Verifying instruction:
   %0 = argument of bb0 : $Subprogress            // users: %1, %2
->   (%2, %3) = destructure_struct %0 : $Subprogress // users: %9, %4
In function:
// Subprogress.start()
// Isolation: unspecified
sil [ossa] @$ss11SubprogressV5startyyF : $@convention(method) (@owned Subprogress) -> () {
[%0: noescape v**, read v**.c*.v**, write v**.c*.v**, copy v**.c*.v**, destroy v**.c*.v**]
[global: read,write,copy,destroy]
// %0 "self"                                      // users: %1, %2
bb0(%0 : @owned $Subprogress):
  debug_value %0, var, name "self"                // id: %1
  (%2, %3) = destructure_struct %0                // users: %9, %4
  debug_value %3, var, name "self", type $Subprogress, expr op_fragment:#Subprogress.isInitializedToProgressReporter // id: %4
  debug_value undef : $*Subprogress, var, name "self" // id: %5
  %6 = struct $S1 ()                              // users: %7, %9
  debug_value %6, var, name "self", type $Subprogress, expr op_fragment:#Subprogress.isInitializedToProgressReporter // id: %7
  debug_value undef : $*Subprogress, var, name "self" // id: %8
  %9 = struct $Subprogress (%2, %6)               // user: %10
  %10 = move_value [lexical] %9                   // user: %12
  %11 = alloc_stack $Subprogress, let, name "self", argno 1 // users: %20, %17, %14, %12
  store %10 to [init] %11                         // id: %12
  debug_value undef : $*Subprogress, let, name "self", argno 1 // id: %13
  %14 = drop_deinit %11                           // user: %16
  debug_value undef : $*Subprogress, let, name "self", argno 1 // id: %15
  debug_value %14, let, name "self", argno 1, expr op_deref // id: %16
  %17 = struct_element_addr %11, #Subprogress.parent // user: %18
  destroy_addr %17                                // id: %18
  debug_value undef : $*Subprogress, let, name "self", argno 1 // id: %19
  dealloc_stack %11                               // id: %20
  %21 = tuple ()                                  // user: %22
  return %21                                      // id: %22
} // end sil function '$ss11SubprogressV5startyyF'

Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.      Program arguments: /home/katei/.local/share/swiftly/toolchains/main-snapshot-2025-11-03/usr/bin/swift-frontend -frontend -c Check.swift -target wasm32-unknown-none -module-name Swift -parse-as-library -emit-sil -O -parse-stdlib
1.      Swift version 6.3-dev (LLVM bff1370bd79c983, Swift 57cf4ce563f700b)
2.      Compiling with effective version 5.10
3.      While evaluating request ExecuteSILPipelineRequest(Run pipelines { PrepareOptimizationPasses, EarlyModulePasses, HighLevel,Function+EarlyLoopOpt, HighLevel,Module+StackPromote, MidLevel,Function, ClosureSpecialize, LowLevel,Function, LateLoopOpt, SIL Debug Info Generator } on SIL for Swift)
4.      While running pass #751 SILFunctionTransform "OwnershipModelEliminator" on SILFunction "@$ss11SubprogressV5startyyF".
 for 'start()' (at Check.swift:14:22)
5.      Found verification error when verifying before lowering ownership. Please re-run with -sil-verify-all to identify the actual pass that introduced the verification error.
6.      While verifying SIL function "@$ss11SubprogressV5startyyF".
 for 'start()' (at Check.swift:14:22)
 #0 0x000055f02e752418 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/katei/.local/share/swiftly/toolchains/main-snapshot-2025-11-03/usr/bin/swift-frontend+0x8958418)
 #1 0x000055f02e74fc05 llvm::sys::RunSignalHandlers() (/home/katei/.local/share/swiftly/toolchains/main-snapshot-2025-11-03/usr/bin/swift-frontend+0x8955c05)
 #2 0x000055f02e7531c1 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #3 0x00007fbcc163f520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007fbcc16939fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x00007fbcc16939fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #6 0x00007fbcc16939fc pthread_kill ./nptl/pthread_kill.c:89:10
 #7 0x00007fbcc163f476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x00007fbcc16257f3 abort ./stdlib/abort.c:81:7
 #9 0x000055f0275c3fcb (/home/katei/.local/share/swiftly/toolchains/main-snapshot-2025-11-03/usr/bin/swift-frontend+0x17c9fcb)
#10 0x000055f0275cf64a swift::SILVisitorBase<(anonymous namespace)::SILVerifier, void>::visitSILBasicBlock(swift::SILBasicBlock*) SILVerifier.cpp:0:0
#11 0x000055f0275cf07f (anonymous namespace)::SILVerifier::visitSILBasicBlock(swift::SILBasicBlock*) SILVerifier.cpp:0:0
#12 0x000055f0275cc78b (anonymous namespace)::SILVerifier::visitSILFunction(swift::SILFunction*) SILVerifier.cpp:0:0
#13 0x000055f0275c4a68 swift::SILFunction::verify(swift::CalleeCache*, bool, bool, bool) const (/home/katei/.local/share/swiftly/toolchains/main-snapshot-2025-11-03/usr/bin/swift-frontend+0x17caa68)
#14 0x000055f027bb4ba0 (anonymous namespace)::OwnershipModelEliminator::run() OwnershipModelEliminator.cpp:0:0
#15 0x000055f02767a32a swift::SILPassManager::runPassOnFunction(unsigned int, swift::SILFunction*) (/home/katei/.local/share/swiftly/toolchains/main-snapshot-2025-11-03/usr/bin/swift-frontend+0x188032a)
#16 0x000055f02767b611 swift::SILPassManager::runFunctionPasses(unsigned int, unsigned int) (/home/katei/.local/share/swiftly/toolchains/main-snapshot-2025-11-03/usr/bin/swift-frontend+0x1881611)
#17 0x000055f027677f98 swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&) (/home/katei/.local/share/swiftly/toolchains/main-snapshot-2025-11-03/usr/bin/swift-frontend+0x187df98)
#18 0x000055f027677f4b swift::ExecuteSILPipelineRequest::evaluate(swift::Evaluator&, swift::SILPipelineExecutionDescriptor) const (/home/katei/.local/share/swiftly/toolchains/main-snapshot-2025-11-03/usr/bin/swift-frontend+0x187df4b)
#19 0x000055f02769f1ba swift::SimpleRequest<swift::ExecuteSILPipelineRequest, std::tuple<> (swift::SILPipelineExecutionDescriptor), (swift::RequestFlags)1>::evaluateRequest(swift::ExecuteSILPipelineRequest const&, swift::Evaluator&) crtstuff.c:0:0
#20 0x000055f02768649a swift::ExecuteSILPipelineRequest::OutputType swift::Evaluator::getResultUncached<swift::ExecuteSILPipelineRequest, swift::ExecuteSILPipelineRequest::OutputType swift::evaluateOrFatal<swift::ExecuteSILPipelineRequest>(swift::Evaluator&, swift::ExecuteSILPipelineRequest)::'lambda'()>(swift::ExecuteSILPipelineRequest const&, swift::ExecuteSILPipelineRequest::OutputType swift::evaluateOrFatal<swift::ExecuteSILPipelineRequest>(swift::Evaluator&, swift::ExecuteSILPipelineRequest)::'lambda'()) crtstuff.c:0:0
#21 0x000055f02767818f swift::executePassPipelinePlan(swift::SILModule*, swift::SILPassPipelinePlan const&, bool, swift::irgen::IRGenModule*) (/home/katei/.local/share/swiftly/toolchains/main-snapshot-2025-11-03/usr/bin/swift-frontend+0x187e18f)
#22 0x000055f027687aeb swift::runSILOptimizationPasses(swift::SILModule&) (/home/katei/.local/share/swiftly/toolchains/main-snapshot-2025-11-03/usr/bin/swift-frontend+0x188daeb)
#23 0x000055f026b53fee swift::CompilerInstance::performSILProcessing(swift::SILModule*) (/home/katei/.local/share/swiftly/toolchains/main-snapshot-2025-11-03/usr/bin/swift-frontend+0xd59fee)
#24 0x000055f0267b7a2c performCompileStepsPostSILGen(swift::CompilerInstance&, std::unique_ptr<swift::SILModule, std::default_delete<swift::SILModule>>, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*, llvm::ArrayRef<char const*>) FrontendTool.cpp:0:0
#25 0x000055f0267b691f swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*, llvm::ArrayRef<char const*>) (/home/katei/.local/share/swiftly/toolchains/main-snapshot-2025-11-03/usr/bin/swift-frontend+0x9bc91f)
#26 0x000055f0267cd3da withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) FrontendTool.cpp:0:0
#27 0x000055f0267bbf99 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*, llvm::ArrayRef<char const*>) FrontendTool.cpp:0:0
#28 0x000055f0267b8bfe swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) (/home/katei/.local/share/swiftly/toolchains/main-snapshot-2025-11-03/usr/bin/swift-frontend+0x9bebfe)
#29 0x000055f026508aec swift::mainEntry(int, char const**) (/home/katei/.local/share/swiftly/toolchains/main-snapshot-2025-11-03/usr/bin/swift-frontend+0x70eaec)
#30 0x00007fbcc1626d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#31 0x00007fbcc1626e40 call_init ./csu/../csu/libc-start.c:128:20
#32 0x00007fbcc1626e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#33 0x000055f0265079d5 _start (/home/katei/.local/share/swiftly/toolchains/main-snapshot-2025-11-03/usr/bin/swift-frontend+0x70d9d5)

Expected behavior

Not crash

Environment

Swift version 6.3-dev (LLVM bff1370bd79c983, Swift 57cf4ce)
Target: x86_64-unknown-linux-gnu
Build config: +assertions

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    SIL ownershipArea → compiler → SIL: SIL ownershipbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.crashBug: A crash, i.e., an abnormal termination of softwaretriage neededThis issue needs more specific labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions