Skip to content

SIL verification failure/miscompile when overriding async getter with non-async implementation #85332

@jamieQ

Description

@jamieQ

Description

failure to include the async effect on an overridden async property getter leads to a SIL verification failure or possible miscompilation.

Reproduction

// compile with an asserts toolchain, or add -Xfrontend -sil-verify-all

class Super {
    var async_prop: Int { get async { 42 } }
}

class Sub: Super {
    override var async_prop: Int { 42 }
}

Stack dump

SIL verification failed: vtable entry for #Super.async_prop!getter must be ABI-compatible
  sync/async mismatch
  @convention(method) (@guaranteed Sub) -> Int
  @convention(method) @async (@guaranteed Super) -> Int
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.	Program arguments: /cefs/4d/4d3809280b7e5bf3503fc85e_swift-nightly/usr/bin/swift-frontend -frontend -S -primary-file <source> -target x86_64-unknown-linux-gnu -disable-objc-interop -no-color-diagnostics -Xcc -fno-color-diagnostics -g -debug-info-format=dwarf -dwarf-version=4 -sil-verify-all -empty-abi-descriptor -enable-anonymous-context-mangled-names -file-compilation-dir /app -Xllvm --x86-asm-syntax=intel -no-auto-bridging-header-chaining -module-name output -in-process-plugin-server-path /cefs/4d/4d3809280b7e5bf3503fc85e_swift-nightly/usr/lib/swift/host/libSwiftInProcPluginServer.so -plugin-path /cefs/4d/4d3809280b7e5bf3503fc85e_swift-nightly/usr/lib/swift/host/plugins -plugin-path /cefs/4d/4d3809280b7e5bf3503fc85e_swift-nightly/usr/local/lib/swift/host/plugins -o /app/output.s
1.	Swift version 6.3-dev (LLVM bff1370bd79c983, Swift 57cf4ce563f700b)
2.	Compiling with effective version 5.10
3.	While evaluating request ASTLoweringRequest(Lowering AST to SIL for file "<source>")
 #0 0x0000579dbb12c418 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/cefs/4d/4d3809280b7e5bf3503fc85e_swift-nightly/usr/bin/swift-frontend+0x8958418)
 #1 0x0000579dbb129c05 llvm::sys::RunSignalHandlers() (/cefs/4d/4d3809280b7e5bf3503fc85e_swift-nightly/usr/bin/swift-frontend+0x8955c05)
 #2 0x0000579dbb12d1c1 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #3 0x0000727c0c442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x0000727c0c4969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x0000727c0c442476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x0000727c0c4287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x0000579db3f9dfcb (/cefs/4d/4d3809280b7e5bf3503fc85e_swift-nightly/usr/bin/swift-frontend+0x17c9fcb)
 #8 0x0000579db3fa1af6 (anonymous namespace)::SILVerifier::requireABICompatibleFunctionTypes(swift::CanTypeWrapper<swift::SILFunctionType>, swift::CanTypeWrapper<swift::SILFunctionType>, llvm::Twine const&, swift::SILFunction&) SILVerifier.cpp:0:0
 #9 0x0000579db3fa1661 swift::SILVTable::verify(swift::SILModule const&) const (/cefs/4d/4d3809280b7e5bf3503fc85e_swift-nightly/usr/bin/swift-frontend+0x17cd661)
#10 0x0000579db3fa2810 swift::SILModule::verify(swift::CalleeCache*, bool, bool) const (/cefs/4d/4d3809280b7e5bf3503fc85e_swift-nightly/usr/bin/swift-frontend+0x17ce810)
#11 0x0000579db3fa255f swift::SILModule::verify(bool, bool) const (/cefs/4d/4d3809280b7e5bf3503fc85e_swift-nightly/usr/bin/swift-frontend+0x17ce55f)
#12 0x0000579db39efdf0 swift::Lowering::SILGenModule::~SILGenModule() crtstuff.c:0:0
#13 0x0000579db39fd2c2 swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const (/cefs/4d/4d3809280b7e5bf3503fc85e_swift-nightly/usr/bin/swift-frontend+0x12292c2)
#14 0x0000579db3b134c6 swift::SimpleRequest<swift::ASTLoweringRequest, std::unique_ptr<swift::SILModule, std::default_delete<swift::SILModule>> (swift::ASTLoweringDescriptor), (swift::RequestFlags)17>::evaluateRequest(swift::ASTLoweringRequest const&, swift::Evaluator&) crtstuff.c:0:0
#15 0x0000579db3a01cb5 swift::ASTLoweringRequest::OutputType swift::Evaluator::getResultUncached<swift::ASTLoweringRequest, swift::ASTLoweringRequest::OutputType swift::evaluateOrFatal<swift::ASTLoweringRequest>(swift::Evaluator&, swift::ASTLoweringRequest)::'lambda'()>(swift::ASTLoweringRequest const&, swift::ASTLoweringRequest::OutputType swift::evaluateOrFatal<swift::ASTLoweringRequest>(swift::Evaluator&, swift::ASTLoweringRequest)::'lambda'()) crtstuff.c:0:0
#16 0x0000579db39fd7cf swift::performASTLowering(swift::FileUnit&, swift::Lowering::TypeConverter&, swift::SILOptions const&, swift::IRGenOptions const*) (/cefs/4d/4d3809280b7e5bf3503fc85e_swift-nightly/usr/bin/swift-frontend+0x12297cf)
#17 0x0000579db3190642 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*, llvm::ArrayRef<char const*>) (/cefs/4d/4d3809280b7e5bf3503fc85e_swift-nightly/usr/bin/swift-frontend+0x9bc642)
#18 0x0000579db31a73da withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) FrontendTool.cpp:0:0
#19 0x0000579db3195f99 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*, llvm::ArrayRef<char const*>) FrontendTool.cpp:0:0
#20 0x0000579db3192bfe swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) (/cefs/4d/4d3809280b7e5bf3503fc85e_swift-nightly/usr/bin/swift-frontend+0x9bebfe)
#21 0x0000579db2ee2aec swift::mainEntry(int, char const**) (/cefs/4d/4d3809280b7e5bf3503fc85e_swift-nightly/usr/bin/swift-frontend+0x70eaec)
#22 0x0000727c0c429d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#23 0x0000727c0c429e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#24 0x0000579db2ee19d5 _start (/cefs/4d/4d3809280b7e5bf3503fc85e_swift-nightly/usr/bin/swift-frontend+0x70d9d5)

Expected behavior

if the code is actually invalid, the bad override should be diagnosed with an error.

Environment

Swift version 6.2 (swift-6.2-RELEASE)
Target: x86_64-unknown-linux-gnu

Additional information

motivating forum thread: https://forums.swift.org/t/is-there-a-warning-about-accidentally-overriding-a-property-with-a-method/82978
godbolt: https://swift.godbolt.org/z/7GYdzEfro

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.triage 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