r344915 - Ensure sanitizer check function calls have a !dbg location

Vlad Tsyrklevich via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 22 15:03:52 PDT 2018


This change causes build failures on the UBSan bot, like so
<http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap-ubsan/builds/7121/steps/build%20clang%2Fubsan/logs/stdio>
:

3.	/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm/include/llvm/Support/Allocator.h:98:40:
Generating code for declaration 'llvm::MallocAllocator::Allocate'

#0 0x000055c1695ee77a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x265677a)
#1 0x000055c1695ecc55 llvm::sys::RunSignalHandlers()
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x2654c55)
#2 0x000055c1695ecd6c SignalHandler(int)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x2654d6c)
#3 0x00007f1e75f880c0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x110c0)
#4 0x000055c169018c69 llvm::DebugLoc::get(unsigned int, unsigned int,
llvm::MDNode const*, llvm::MDNode const*, bool)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x2080c69)
#5 0x000055c1697ddb31
clang::CodeGen::CGDebugInfo::EmitLocation(clang::CodeGen::CGBuilderTy&,
clang::SourceLocation)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x2845b31)
#6 0x000055c1697ddcd6
clang::CodeGen::ApplyDebugLocation::init(clang::SourceLocation, bool)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x2845cd6)
#7 0x000055c1699defa6
emitCheckHandlerCall(clang::CodeGen::CodeGenFunction&,
llvm::FunctionType*, llvm::ArrayRef<llvm::Value*>,
clang::CodeGen::SanitizerHandler, (anonymous
namespace)::CheckRecoverableKind, bool, llvm::BasicBlock*)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x2a46fa6)
#8 0x000055c1699e155a
clang::CodeGen::CodeGenFunction::EmitCheck(llvm::ArrayRef<std::pair<llvm::Value*,
unsigned long> >, clang::CodeGen::SanitizerHandler,
llvm::ArrayRef<llvm::Constant*>, llvm::ArrayRef<llvm::Value*>)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x2a4955a)
#9 0x000055c169991463
clang::CodeGen::CodeGenFunction::EmitReturnValueCheck(llvm::Value*)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x29f9463)
#10 0x000055c16999f536
clang::CodeGen::CodeGenFunction::EmitFunctionEpilog(clang::CodeGen::CGFunctionInfo
const&, bool, clang::SourceLocation)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x2a07536)
#11 0x000055c16985070a
clang::CodeGen::CodeGenFunction::FinishFunction(clang::SourceLocation)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x28b870a)
#12 0x000055c16985959f
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x28c159f)
#13 0x000055c169895ac5
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl,
llvm::GlobalValue*)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x28fdac5)
#14 0x000055c169892c39
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x28fac39)
#15 0x000055c169898992 clang::CodeGen::CodeGenModule::EmitDeferred()
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x2900992)
#16 0x000055c1698989ac clang::CodeGen::CodeGenModule::EmitDeferred()
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x29009ac)
#17 0x000055c1698989ac clang::CodeGen::CodeGenModule::EmitDeferred()
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x29009ac)
#18 0x000055c1698989ac clang::CodeGen::CodeGenModule::EmitDeferred()
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x29009ac)
#19 0x000055c1698989ac clang::CodeGen::CodeGenModule::EmitDeferred()
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x29009ac)
#20 0x000055c169898af3 clang::CodeGen::CodeGenModule::Release()
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x2900af3)
#21 0x000055c169fae527 (anonymous
namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x3016527)
#22 0x000055c169fad156
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x3015156)
#23 0x000055c16a7b9569 clang::ParseAST(clang::Sema&, bool, bool)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x3821569)
#24 0x000055c169fac339 clang::CodeGenAction::ExecuteAction()
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x3014339)
#25 0x000055c169c2d25e clang::FrontendAction::Execute()
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x2c9525e)
#26 0x000055c169bf7b0e
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x2c5fb0e)
#27 0x000055c169cd0f51
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x2d38f51)
#28 0x000055c167c34760 cc1_main(llvm::ArrayRef<char const*>, char
const*, void*) (/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0xc9c760)
#29 0x000055c167b9ea92 main
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0xc06a92)

I've reverted it in r344961.

On Mon, Oct 22, 2018 at 9:29 AM Adrian Prantl via cfe-commits <
cfe-commits at lists.llvm.org> wrote:

> Author: adrian
> Date: Mon Oct 22 09:27:41 2018
> New Revision: 344915
>
> URL: http://llvm.org/viewvc/llvm-project?rev=344915&view=rev
> Log:
> Ensure sanitizer check function calls have a !dbg location
>
> Function calls without a !dbg location inside a function that has a
> DISubprogram make it impossible to construct inline information and
> are rejected by the verifier. This patch ensures that sanitizer check
> function calls have a !dbg location, by carrying forward the location
> of the preceding instruction or by inserting an artificial location if
> necessary.
>
> This fixes a crash when compiling the attached testcase with -Os.
>
> rdar://problem/45311226
>
> Differential Revision: https://reviews.llvm.org/D53459
>
> Added:
>     cfe/trunk/test/CodeGenCXX/ubsan-check-debuglocs.cpp
> Modified:
>     cfe/trunk/lib/CodeGen/CGExpr.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=344915&r1=344914&r2=344915&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Oct 22 09:27:41 2018
> @@ -2867,6 +2867,9 @@ static void emitCheckHandlerCall(CodeGen
>                                   CheckRecoverableKind RecoverKind, bool
> IsFatal,
>                                   llvm::BasicBlock *ContBB) {
>    assert(IsFatal || RecoverKind != CheckRecoverableKind::Unrecoverable);
> +  auto *DI = CGF.getDebugInfo();
> +  SourceLocation Loc = DI ? DI->getLocation() : SourceLocation();
> +  auto DL = ApplyDebugLocation::CreateDefaultArtificial(CGF, Loc);
>    bool NeedsAbortSuffix =
>        IsFatal && RecoverKind != CheckRecoverableKind::Unrecoverable;
>    bool MinimalRuntime = CGF.CGM.getCodeGenOpts().SanitizeMinimalRuntime;
>
> Added: cfe/trunk/test/CodeGenCXX/ubsan-check-debuglocs.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/ubsan-check-debuglocs.cpp?rev=344915&view=auto
>
> ==============================================================================
> --- cfe/trunk/test/CodeGenCXX/ubsan-check-debuglocs.cpp (added)
> +++ cfe/trunk/test/CodeGenCXX/ubsan-check-debuglocs.cpp Mon Oct 22
> 09:27:41 2018
> @@ -0,0 +1,17 @@
> +// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited \
> +// RUN:   -fsanitize=null %s -o - | FileCheck %s
> +
> +// Check that santizer check calls have a !dbg location.
> +// CHECK: define {{.*}}acquire{{.*}} !dbg
> +// CHECK-NOT: define
> +// CHECK: call void {{.*}}@__ubsan_handle_type_mismatch_v1
> +// CHECK-SAME: !dbg
> +
> +struct SourceLocation {
> +  SourceLocation acquire() {};
> +};
> +extern "C" void __ubsan_handle_type_mismatch_v1(SourceLocation *Loc);
> +static void handleTypeMismatchImpl(SourceLocation *Loc) { Loc->acquire();
> }
> +void __ubsan_handle_type_mismatch_v1(SourceLocation *Loc) {
> +  handleTypeMismatchImpl(Loc);
> +}
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181022/86dd405d/attachment-0001.html>


More information about the cfe-commits mailing list