[llvm-bugs] [Bug 40941] New: 4.5 Billion line file use 15GB of RAM

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Mar 3 09:31:29 PST 2019


https://bugs.llvm.org/show_bug.cgi?id=40941

            Bug ID: 40941
           Summary: 4.5 Billion line file use 15GB of RAM
           Product: clang
           Version: 7.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: jg at jguk.org
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

GCC handles 4.5 Billion line file ok. Using ~8.64GB of RAM.
 Clang 7 goes up to 15GB. Clang 6 rushes up to limit and crashes.

Would be better if it managed to use less RAM than GCC at least.


Any file will do, eg. this test case

// gcc -Wall -o cre_line cre_line.c

#include <stdio.h>

int main()
{
    printf("int main() {\n");

    for(size_t i = 0; i != 4500000000; ++i)
    {
        printf("\n");
    }

    printf("#warning msg1\n return 0; }\n\n");

    return 0;
}

this is clang 6, sorry clang 8 doesn't appear to be in Ubuntu stable.

$ clang -Wall -o test2 test.c
LLVM ERROR: out of memory
#0 0x00007ff82f3640ea llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/lib/llvm-6.0/bin/../lib/libLLVM-6.0.so.1+0x81e0ea)
#1 0x00007ff82f362366 llvm::sys::RunSignalHandlers()
(/usr/lib/llvm-6.0/bin/../lib/libLLVM-6.0.so.1+0x81c366)
#2 0x00007ff82f36249b (/usr/lib/llvm-6.0/bin/../lib/libLLVM-6.0.so.1+0x81c49b)
#3 0x00007ff8325f4890 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)
#4 0x00007ff82dc22e97 gsignal
/build/glibc-OTsEL5/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
#5 0x00007ff82dc24801 abort /build/glibc-OTsEL5/glibc-2.27/stdlib/abort.c:81:0
#6 0x00007ff82f2f712b llvm::report_bad_alloc_error(char const*, bool)
(/usr/lib/llvm-6.0/bin/../lib/libLLVM-6.0.so.1+0x7b112b)
#7 0x00007ff82f30e2a1 llvm::SmallVectorBase::grow_pod(void*, unsigned long,
unsigned long) (/usr/lib/llvm-6.0/bin/../lib/libLLVM-6.0.so.1+0x7c82a1)
#8 0x000055825925fc3b (/usr/lib/llvm-6.0/bin/clang+0x46ec3b)
#9 0x000055825926004d clang::SourceManager::getLineNumber(clang::FileID,
unsigned int, bool*) const (/usr/lib/llvm-6.0/bin/clang+0x46f04d)
#10 0x0000558259261dbd
clang::SourceManager::getPresumedLoc(clang::SourceLocation, bool) const
(/usr/lib/llvm-6.0/bin/clang+0x470dbd)
#11 0x000055825a98a569 clang::FullSourceLoc::getPresumedLoc(bool) const
(/usr/lib/llvm-6.0/bin/clang+0x1b99569)
#12 0x000055825971ef08
clang::DiagnosticRenderer::emitDiagnostic(clang::FullSourceLoc,
clang::DiagnosticsEngine::Level, llvm::StringRef,
llvm::ArrayRef<clang::CharSourceRange>, llvm::ArrayRef<clang::FixItHint>,
llvm::PointerUnion<clang::Diagnostic const*, clang::StoredDiagnostic const*>)
(/usr/lib/llvm-6.0/bin/clang+0x92df08)
#13 0x00005582596c66f5
clang::TextDiagnosticPrinter::HandleDiagnostic(clang::DiagnosticsEngine::Level,
clang::Diagnostic const&) (/usr/lib/llvm-6.0/bin/clang+0x8d56f5)
#14 0x00005582592563f0
clang::DiagnosticIDs::EmitDiag(clang::DiagnosticsEngine&,
clang::DiagnosticIDs::Level) const (/usr/lib/llvm-6.0/bin/clang+0x4653f0)
#15 0x0000558259257f0a
clang::DiagnosticIDs::ProcessDiag(clang::DiagnosticsEngine&) const
(/usr/lib/llvm-6.0/bin/clang+0x466f0a)
#16 0x0000558259250963 clang::DiagnosticsEngine::EmitCurrentDiagnostic(bool)
(/usr/lib/llvm-6.0/bin/clang+0x45f963)
#17 0x000055825a914435
clang::Preprocessor::HandleUserDiagnosticDirective(clang::Token&, bool)
(/usr/lib/llvm-6.0/bin/clang+0x1b23435)
#18 0x000055825a91f412 clang::Preprocessor::HandleDirective(clang::Token&)
(/usr/lib/llvm-6.0/bin/clang+0x1b2e412)
#19 0x000055825a8e62ad clang::Lexer::LexTokenInternal(clang::Token&, bool)
(/usr/lib/llvm-6.0/bin/clang+0x1af52ad)
#20 0x000055825a959e0f clang::Preprocessor::Lex(clang::Token&)
(/usr/lib/llvm-6.0/bin/clang+0x1b68e0f)
#21 0x0000558259af6b9e (/usr/lib/llvm-6.0/bin/clang+0xd05b9e)
#22 0x0000558259b8b97e clang::Parser::ParseCompoundStatementBody(bool)
(/usr/lib/llvm-6.0/bin/clang+0xd9a97e)
#23 0x0000558259b8e559 clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&) (/usr/lib/llvm-6.0/bin/clang+0xd9d559)
#24 0x0000558259afe94b
clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*)
(/usr/lib/llvm-6.0/bin/clang+0xd0d94b)
#25 0x0000558259b1ffdf clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*)
(/usr/lib/llvm-6.0/bin/clang+0xd2efdf)
#26 0x0000558259afa0d1
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
(/usr/lib/llvm-6.0/bin/clang+0xd090d1)
#27 0x0000558259afa729 (/usr/lib/llvm-6.0/bin/clang+0xd09729)
#28 0x0000558259b009e5
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) (/usr/lib/llvm-6.0/bin/clang+0xd0f9e5)
#29 0x0000558259b019d9
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
(/usr/lib/llvm-6.0/bin/clang+0xd109d9)
#30 0x0000558259b01ca0
clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
(/usr/lib/llvm-6.0/bin/clang+0xd10ca0)
#31 0x0000558259af67fb clang::ParseAST(clang::Sema&, bool, bool)
(/usr/lib/llvm-6.0/bin/clang+0xd057fb)
#32 0x0000558259849a27 clang::CodeGenAction::ExecuteAction()
(/usr/lib/llvm-6.0/bin/clang+0xa58a27)
#33 0x0000558259680b56 clang::FrontendAction::Execute()
(/usr/lib/llvm-6.0/bin/clang+0x88fb56)
#34 0x000055825964abfc
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/lib/llvm-6.0/bin/clang+0x859bfc)
#35 0x000055825972bf13
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/lib/llvm-6.0/bin/clang+0x93af13)
#36 0x0000558259249e08 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/lib/llvm-6.0/bin/clang+0x458e08)
#37 0x0000558259238807 main (/usr/lib/llvm-6.0/bin/clang+0x447807)
#38 0x00007ff82dc05b97 __libc_start_main
/build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:344:0
#39 0x00005582592478aa _start (/usr/lib/llvm-6.0/bin/clang+0x4568aa)
Stack dump:
0.      Program arguments: /usr/lib/llvm-6.0/bin/clang -cc1 -triple
x86_64-pc-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier
-discard-value-names -main-file-name test.c -mrelocation-model static
-mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose
-mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64
-dwarf-column-info -debugger-tuning=gdb -resource-dir
/usr/lib/llvm-6.0/lib/clang/6.0.0 -internal-isystem /usr/local/include
-internal-isystem /usr/lib/llvm-6.0/lib/clang/6.0.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include -Wall
-fdebug-compilation-dir /home/jonny/code/line4 -ferror-limit 19
-fmessage-length 80 -fobjc-runtime=gcc -fdiagnostics-show-option
-fcolor-diagnostics -o /tmp/test-f162f6.o -x c test.c 
1.      clang: error: unable to execute command: Alarm clock
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang: note: diagnostic msg: PLEASE submit a bug report to
http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and
associated run script.
clang: error: unable to execute command: Aborted
clang: note: diagnostic msg: Error generating preprocessed source(s).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190303/d2947274/attachment.html>


More information about the llvm-bugs mailing list