[Bug 41965] New: LLVM ERROR: out of memory

Bug ID 41965
Summary LLVM ERROR: out of memory
Product lldb
Version unspecified
Hardware PC
OS Linux
Status NEW
Severity enhancement
Priority P
Component All Bugs
Assignee lldb-dev@lists.llvm.org
Reporter kkleine@redhat.com
CC jdevlieghere@apple.com, llvm-bugs@lists.llvm.org

I cloned the LLVM monorepo into ~/dev/llvm-project and created an out of source
build directory in which I configured the project to enable clang, lldb and
lld. I want to generate coverage information, so I've set
-DLLVM_BUILD_INSTRUMENTED_COVERAGE=ON.

        cmake ~/dev/llvm-project/llvm \
        -DLLVM_ENABLE_PROJECTS="clang;lldb;lld" \
        -DBUILD_SHARED_LIBS=ON \
        -DCMAKE_BUILD_TYPE=Release \
        -DLLVM_BUILD_INSTRUMENTED_COVERAGE=ON \
        -DCMAKE_CXX_COMPILER=/usr/bin/clang++ \
        -DCMAKE_C_COMPILER=/usr/bin/clang

Then I've built the lldb tartget and it fails (reproducible) with this out of
memory error. What's strange is that I have plenty (18Gig + 10Gig Swap) of
memory free.

Scanning dependencies of target LLVMBPFAsmParser
[ 58%] Building CXX object
lib/Target/BPF/AsmParser/CMakeFiles/LLVMBPFAsmParser.dir/BPFAsmParser.cpp.o
LLVM ERROR: out of memory
Stack dump:
0.      Program arguments: /usr/bin/clang-7 -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -disable-free -disable-llvm-verifier
-discard-value-names -main-file-name AMDGPUBaseInfo.cpp -mrelocation-model pic
-pic-level 2 -mthread-model posix -fmath-errno -masm-verbose
-mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64
-dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer
-ffunction-sections -fdata-sections
-fprofile-instrument-path=/home/kkleine/llvm-builds/coverage-ninja-clang-from-serge/profiles/%4m.profraw
-fprofile-instrument=clang -fcoverage-mapping -coverage-notes-file
/home/kkleine/llvm-builds/coverage-ninja-clang-from-serge/lib/Target/AMDGPU/Utils/CMakeFiles/LLVMAMDGPUUtils.dir/AMDGPUBaseInfo.cpp.gcno
-resource-dir /usr/lib64/clang/7.0.1 -D GTEST_HAS_RTTI=0 -D _GNU_SOURCE -D
__STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I
/home/kkleine/llvm-builds/coverage-ninja-clang-from-serge/lib/Target/AMDGPU/Utils
-I /home/kkleine/dev/llvm-project/llvm/lib/Target/AMDGPU/Utils -I
/home/kkleine/dev/llvm-project/llvm/lib/Target/AMDGPU -I
/home/kkleine/llvm-builds/coverage-ninja-clang-from-serge/lib/Target/AMDGPU -I
/usr/include/libxml2 -I
/home/kkleine/llvm-builds/coverage-ninja-clang-from-serge/include -I
/home/kkleine/dev/llvm-project/llvm/include -D NDEBUG -internal-isystem
/usr/bin/../lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8
-internal-isystem
/usr/bin/../lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8/x86_64-redhat-linux
-internal-isystem
/usr/bin/../lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8/backward
-internal-isystem /usr/local/include -internal-isystem
/usr/lib64/clang/7.0.1/include -internal-externc-isystem /include
-internal-externc-isystem /usr/include -O2 -Werror=date-time
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wno-long-long
-Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type
-Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -pedantic
-std=c++11 -fdeprecated-macro -fdebug-compilation-dir
/home/kkleine/llvm-builds/coverage-ninja-clang-from-serge/lib/Target/AMDGPU/Utils
-ferror-limit 19 -fmessage-length 204 -fvisibility-inlines-hidden -fno-rtti
-fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics
-vectorize-loops -vectorize-slp -o
CMakeFiles/LLVMAMDGPUUtils.dir/AMDGPUBaseInfo.cpp.o -x c++
/home/kkleine/dev/llvm-project/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
-faddrsig 
1.      <eof> parser at end of file
2.      Per-file LLVM IR generation
#0 0x00007f266489909e llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/lib64/libLLVM-7.so+0x9b409e)
#1 0x00007f2664897554 llvm::sys::RunSignalHandlers()
(/lib64/libLLVM-7.so+0x9b2554)
#2 0x00007f26648976d5 (/lib64/libLLVM-7.so+0x9b26d5)
#3 0x00007f2663ed6070 __restore_rt (/lib64/libpthread.so.0+0x13070)
#4 0x00007f2662e8257f __GI_raise (/lib64/libc.so.6+0x3857f)
#5 0x00007f2662e6c895 __GI_abort (/lib64/libc.so.6+0x22895)
#6 0x00007f266481be34 llvm::report_bad_alloc_error(char const*, bool)
(/lib64/libLLVM-7.so+0x936e34)
#7 0x00007f2663246b34 operator new(unsigned long)
(/lib64/libstdc++.so.6+0x97b34)
#8 0x00007f2663a5a8f7 clang::CodeGen::CoverageMappingModuleGen::emit()
(/lib64/libclangCodeGen.so.7+0x3958f7)
#9 0x00007f2663a1dbe0 clang::CodeGen::CodeGenModule::Release()
(/lib64/libclangCodeGen.so.7+0x358be0)
#10 0x00007f2663a88f1a (/lib64/libclangCodeGen.so.7+0x3c3f1a)
#11 0x00007f26639c7a2f (/lib64/libclangCodeGen.so.7+0x302a2f)
#12 0x00007f2662755417 clang::ParseAST(clang::Sema&, bool, bool)
(/lib64/libclangParse.so.7+0x3c417)
#13 0x00007f26639c50ca clang::CodeGenAction::ExecuteAction()
(/lib64/libclangCodeGen.so.7+0x3000ca)
#14 0x00007f26634417a6 clang::FrontendAction::Execute()
(/lib64/libclangFrontend.so.7+0xee7a6)
#15 0x00007f26633fc2fe
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/lib64/libclangFrontend.so.7+0xa92fe)
#16 0x00007f266334caa8
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/lib64/libclangFrontendTool.so.7+0x5aa8)
#17 0x000055ba6cab7f98 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/bin/clang-7+0x15f98)
#18 0x000055ba6cab3ab8 main (/usr/bin/clang-7+0x11ab8)
#19 0x00007f2662e6e413 __libc_start_main (/lib64/libc.so.6+0x24413)
#20 0x000055ba6cab463e _start (/usr/bin/clang-7+0x1263e)
clang-7: error: unable to execute command: Aborted (core dumped)
clang-7: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 7.0.1 (Fedora 7.0.1-6.fc29)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang-7: note: diagnostic msg: PLEASE submit a bug report to  and include the
crash backtrace, preprocessed source, and associated run script.
[ 58%] Building CXX object lib/Object/CMakeFiles/LLVMObject.dir/Binary.cpp.o
clang-7: note: diagnostic msg:

sguelton@redhat.com changed bug 41965

What Removed Added
Resolution FIXED
Status CONFIRMED RESOLVED

Comment # 6 on bug 41965 from sguelton@redhat.com

Fixed by [https://reviews.llvm.org/rG4cd07dbeec9811a98efbc0ed3518e78dc38c0f53](https://reviews.llvm.org/rG4cd07dbeec9811a98efbc0ed3518e78dc38c0f53)

Raphael Isemann changed bug 41965