[PATCH] D104898: [clang-repl] Allow passing in code as positional arguments.

Vassil Vassilev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Jul 10 10:40:55 PDT 2021


v.g.vassilev added a comment.

In D104898#2855751 <https://reviews.llvm.org/D104898#2855751>, @hctim wrote:

> Hi, looks like this change caused a regression on the sanitizer buildbots (https://lab.llvm.org/buildbot/#/builders/169/builds/1290/steps/25/logs/stdio). Error copied below for your convenience.
>
> Can be repro'd using the bot instructions at https://github.com/google/sanitizers/wiki/SanitizerBotReproduceBuild, or (should be possible) by using `cmake -DLLVM_USE_SANITIZER=Address -GNinja && ninja check-clang`.
>
>   ******************** TEST 'Clang :: Interpreter/execute.cpp' FAILED ********************
>   Script:
>   --
>   : 'RUN: at line 1';   /b/sanitizer-x86_64-linux-fast/build/llvm_build_asan/bin/clang-repl "int i = 10;" 'extern "C" int printf(const char*,...);'             'auto r1 = printf("i = %d\n", i);' | /b/sanitizer-x86_64-linux-fast/build/llvm_build_asan/bin/FileCheck --check-prefix=CHECK-DRIVER /b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Interpreter/execute.cpp
>   : 'RUN: at line 8';   cat /b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Interpreter/execute.cpp | /b/sanitizer-x86_64-linux-fast/build/llvm_build_asan/bin/clang-repl | /b/sanitizer-x86_64-linux-fast/build/llvm_build_asan/bin/FileCheck /b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Interpreter/execute.cpp
>   --
>   Exit Code: 1
>   Command Output (stderr):
>   --
>   =================================================================
>   ==67042==ERROR: LeakSanitizer: detected memory leaks
>   Direct leak of 3384 byte(s) in 3 object(s) allocated from:
>       #0 0x44fbefd in operator new(unsigned long) /b/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/lib/asan/asan_new_delete.cpp:95:3
>       #1 0x4bb65ad in llvm::RegisterTargetMachine<llvm::X86TargetMachine>::Allocator(llvm::Target const&, llvm::Triple const&, llvm::StringRef, llvm::StringRef, llvm::TargetOptions const&, llvm::Optional<llvm::Reloc::Model>, llvm::Optional<llvm::CodeModel::Model>, llvm::CodeGenOpt::Level, bool) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/Support/TargetRegistry.h:1209:12
>       #2 0x6acad7f in createTargetMachine /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/Support/TargetRegistry.h:429:12
>       #3 0x6acad7f in (anonymous namespace)::EmitAssemblyHelper::CreateTargetMachine(bool) /b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:907:23
>       #4 0x6ab5a43 in (anonymous namespace)::EmitAssemblyHelper::EmitAssemblyWithNewPassManager(clang::BackendAction, std::__1::unique_ptr<llvm::raw_pwrite_stream, std::__1::default_delete<llvm::raw_pwrite_stream> >) /b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1195:3
>       #5 0x6aac51b in clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, std::__1::unique_ptr<llvm::raw_pwrite_stream, std::__1::default_delete<llvm::raw_pwrite_stream> >) /b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1654:15
>       #6 0x6aa0610 in clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:334:7
>       #7 0x59ba3bf in clang::IncrementalParser::ParseOrWrapTopLevelDecl() /b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Interpreter/IncrementalParser.cpp:177:13
>       #8 0x59bc084 in clang::IncrementalParser::Parse(llvm::StringRef) /b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Interpreter/IncrementalParser.cpp:227:27
>       #9 0x585dd64 in clang::Interpreter::Parse(llvm::StringRef) /b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/lib/Interpreter/Interpreter.cpp:202:22
>       #10 0x4501f45 in clang::Interpreter::ParseAndExecute(llvm::StringRef) /b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/include/clang/Interpreter/Interpreter.h:61:29
>       #11 0x4500605 in main /b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/tools/clang-repl/ClangRepl.cpp:95:30
>       #12 0x7f625d26909a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)

Thanks @hctim!

I can reproduce the issue and I have a fix but I do not understand it:

  diff
  diff --git a/clang/test/Interpreter/execute.cpp b/clang/test/Interpreter/execute.cpp
  index 730796bd4016..298046c068c3 100644
  --- a/clang/test/Interpreter/execute.cpp
  +++ b/clang/test/Interpreter/execute.cpp
  @@ -2,11 +2,8 @@
   // RUN:            'auto r1 = printf("i = %d\n", i);' | FileCheck --check-prefix=CHECK-DRIVER %s
   // REQUIRES: host-supports-jit
   // UNSUPPORTED: system-aix
  -
   // CHECK-DRIVER: i = 10
  -
   // RUN: cat %s | clang-repl | FileCheck %s
  -
   extern "C" int printf(const char *, ...);
   int i = 42;
   auto r1 = printf("i = %d\n", i);
  @@ -16,5 +13,4 @@ struct S { float f = 1.0; S *m = nullptr;} s;
   
   auto r2 = printf("S[f=%f, m=0x%llx]\n", s.f, reinterpret_cast<unsigned long long>(s.m));
   // CHECK-NEXT: S[f=1.000000, m=0x0]
  -
   quit

The original test in `execute.cpp` failed not the one that this review introduces. I suspect that somehow the `cat` command fails to pipe the `quit` to the interpreter due to new/empty lines...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104898/new/

https://reviews.llvm.org/D104898



More information about the cfe-commits mailing list