Skip to content

Assertion failed: (address.getType().isAddress()), function emitTsanInoutAccess, file SILGenLValue.cpp when thread sanitizer is enabled #83309

@ahoppen

Description

@ahoppen

Emitting SIL for the following code hits an assertion failure when passing -sanitize=thread.

struct Foo: ~Copyable {
    let underlying: UnsafeMutablePointer<Bar>

    init(underlying: UnsafeMutablePointer<Bar>) {
        self.underlying = underlying
    }

    func doIt() throws {
        underlying.pointee.doIt()
    }
}


struct Bar: ~Copyable {
    mutating func doIt() {}
}

Stack trace:

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib        	       0x18fa69388 __pthread_kill + 8
1   libsystem_pthread.dylib       	       0x18faa288c pthread_kill + 296
2   libsystem_c.dylib             	       0x18f9abcf0 __abort + 132
3   libsystem_c.dylib             	       0x18f9abc6c abort + 136
4   libsystem_c.dylib             	       0x18f9aaeec __assert_rtn + 284
5   swift-frontend                	       0x107d22558 drillIntoComponent(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::Lowering::PathComponent&&, swift::Lowering::ManagedValue, swift::Lowering::TSanKind) (.cold.3) + 40
6   swift-frontend                	       0x102c05a5c drillIntoComponent(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::Lowering::PathComponent&&, swift::Lowering::ManagedValue, swift::Lowering::TSanKind) + 432
7   swift-frontend                	       0x102c03484 swift::Lowering::SILGenFunction::emitAddressOfLValue(swift::SILLocation, swift::Lowering::LValue&&, swift::Lowering::TSanKind) + 136
8   swift-frontend                	       0x102b6b2e8 (anonymous namespace)::DelayedArgument::emit(swift::Lowering::SILGenFunction&, llvm::SmallVectorImpl<swift::Lowering::ManagedValue>&, unsigned long&) + 308
9   swift-frontend                	       0x102b58d14 emitDelayedArguments(swift::Lowering::SILGenFunction&, llvm::MutableArrayRef<(anonymous namespace)::DelayedArgument>, llvm::MutableArrayRef<llvm::SmallVector<swift::Lowering::ManagedValue, 4u>>) + 444
10  swift-frontend                	       0x102b713a8 (anonymous namespace)::CallEmission::emitArgumentsForNormalApply(swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::SILFunctionType>, llvm::ArrayRef<swift::LifetimeDependenceInfo>, swift::ForeignInfo const&, llvm::SmallVectorImpl<swift::Lowering::ManagedValue>&, std::__1::optional<swift::SILLocation>&) + 1432
11  swift-frontend                	       0x102b5c1a0 (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) + 1812
12  swift-frontend                	       0x102b5a83c swift::Lowering::SILGenFunction::emitApplyExpr(swift::ApplyExpr*, swift::Lowering::SGFContext) + 2020
13  swift-frontend                	       0x102bbad28 swift::Lowering::SILGenFunction::emitIgnoredExpr(swift::Expr*) + 920
14  swift-frontend                	       0x102c4d42c swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 4236
15  swift-frontend                	       0x102c4c394 swift::Lowering::SILGenFunction::emitStmt(swift::Stmt*) + 24
16  swift-frontend                	       0x102be0544 swift::Lowering::SILGenFunction::emitFunction(swift::FuncDecl*) + 436
17  swift-frontend                	       0x102b48170 swift::Lowering::SILGenModule::emitFunctionDefinition(swift::SILDeclRef, swift::SILFunction*) + 6068
18  swift-frontend                	       0x102b4914c swift::Lowering::SILGenModule::emitOrDelayFunction(swift::SILDeclRef) + 268
19  swift-frontend                	       0x102b46984 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 184
20  swift-frontend                	       0x102c623b8 (anonymous namespace)::SILGenType::visitFuncDecl(swift::FuncDecl*) + 28
21  swift-frontend                	       0x102c5ea68 (anonymous namespace)::SILGenType::emitType() + 276
22  swift-frontend                	       0x102c5e948 swift::Lowering::SILGenModule::visitNominalTypeDecl(swift::NominalTypeDecl*) + 24
23  swift-frontend                	       0x102b4bc90 swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*) + 176
24  swift-frontend                	       0x102b4c1ac swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const + 632
25  swift-frontend                	       0x102c4bd70 swift::SimpleRequest<swift::ASTLoweringRequest, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>> (swift::ASTLoweringDescriptor), (swift::RequestFlags)17>::evaluateRequest(swift::ASTLoweringRequest const&, swift::Evaluator&) + 148
26  swift-frontend                	       0x102b50304 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'()) + 340
27  swift-frontend                	       0x102b4c518 swift::performASTLowering(swift::ModuleDecl*, swift::Lowering::TypeConverter&, swift::SILOptions const&, swift::IRGenOptions const*) + 136
28  swift-frontend                	       0x10257d27c swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 2340
29  swift-frontend                	       0x10258ce88 withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 164
30  swift-frontend                	       0x102580b8c performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 716
31  swift-frontend                	       0x10257e3f0 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2380
32  swift-frontend                	       0x1022fe944 swift::mainEntry(int, char const**) + 3064
33  dyld                          	       0x18f702b98 start + 6076

rdar://156627919

Metadata

Metadata

Assignees

No one assigned

    Labels

    SILGenArea → compiler: The SIL generation stagecrashBug: A crash, i.e., an abnormal termination of software

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions