llvm / llvm/llvm-project

translation unit is too large for Clang to process: ran out of source locations clang version 21.1.8 (RESF 21.1.8-2.el9)

Open
#206,930 2 comments 0 reactions 0 assignees View on GitHub
clang:frontend crash
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

0. Program arguments: clang -S -emit-llvm -o min2.ll min2.cpp
1. min2.cpp:8529875:1: current parser token 'assert'

The example min2.cpp is 20000010 lines.
It and its include file can be found in zip file:
http://www.cs.ucl.ac.uk/staff/W.Langdon/bug_125446/bug_125446_loop.zip
On Linux Clang 21 takes approx 12 GB and 2 minutes before reporting:
fatal error: translation unit is too large for Clang to process:
ran out of source locations
clang++: error: clang frontend command failed with exit code 70 (use -v to see invocation)

One example of diagnostic information produced by clang++ is in zip file
http://www.cs.ucl.ac.uk/staff/W.Langdon/bug_125446/min2-464462.zip
Also note g++ loops on this example.

I have tried various command lines which fail in the same way
but in case any of the diagnostic information is interesting I will include them next

```
time clang++ -v -Wall -std=c++11 min2.cpp -o min2 ; echo "status $status"
clang version 21.1.8 (RESF 21.1.8-2.el9)
Target: x86_64-redhat-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Configuration file: /etc/clang/x86_64-redhat-linux-gnu-clang++.cfg
System configuration file directory: /etc/clang/
Selected GCC installation: /opt/rh/gcc-toolset-15/root//usr/lib/gcc/x86_64-redhat-linux/15
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
"/usr/bin/clang-21" -cc1 -triple x86_64-redhat-linux-gnu -emit-obj -dumpdir min2- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name min2.cpp -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -dwarf-version=4 -debugger-tuning=gdb -fdebug-compilation-dir=/tmp/ucacbbl/bug_125446 -v -fcoverage-compilation-dir=/tmp/ucacbbl/bug_125446 -resource-dir /usr/bin/../lib/clang/21 -internal-isystem /opt/rh/gcc-toolset-15/root//usr/lib/gcc/x86_64-redhat-linux/15/../../../../include/c++/15 -internal-isystem /opt/rh/gcc-toolset-15/root//usr/lib/gcc/x86_64-redhat-linux/15/../../../../include/c++/15/x86_64-redhat-linux -internal-isystem /opt/rh/gcc-toolset-15/root//usr/lib/gcc/x86_64-redhat-linux/15/../../../../include/c++/15/backward -internal-isystem /usr/bin/../lib/clang/21/include -internal-isystem /usr/local/include -internal-isystem /opt/rh/gcc-toolset-15/root//usr/lib/gcc/x86_64-redhat-linux/15/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wall -std=c++11 -fdeprecated-macro -ferror-limit 19 -fmessage-length=80 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/min2-0e364b.o -x c++ min2.cpp
clang -cc1 version 21.1.8 based upon LLVM 21.1.8 default target x86_64-redhat-linux-gnu
ignoring nonexistent directory "/opt/rh/gcc-toolset-15/root//usr/lib/gcc/x86_64-redhat-linux/15/../../../../x86_64-redhat-linux/include"
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
/opt/rh/gcc-toolset-15/root//usr/lib/gcc/x86_64-redhat-linux/15/../../../../include/c++/15
/opt/rh/gcc-toolset-15/root//usr/lib/gcc/x86_64-redhat-linux/15/../../../../include/c++/15/x86_64-redhat-linux
/opt/rh/gcc-toolset-15/root//usr/lib/gcc/x86_64-redhat-linux/15/../../../../include/c++/15/backward
/usr/bin/../lib/clang/21/include
/usr/local/include
/usr/include
End of search list.
fatal error: translation unit is too large for Clang to process:
ran out of source locations
clang++: error: clang frontend command failed with exit code 70 (use -v to see invocation)
clang version 21.1.8 (RESF 21.1.8-2.el9)
Target: x86_64-redhat-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Configuration file: /etc/clang/x86_64-redhat-linux-gnu-clang++.cfg
clang++: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang++: note: diagnostic msg: /tmp/min2-464462.cpp
clang++: note: diagnostic msg: /tmp/min2-464462.sh
clang++: note: diagnostic msg:

********************
105.724u 2.871s 1:49.05 99.5% 0+0k 0+1252520io 0pf+0w
status 1

time clang++ -Wall -std=c++11 min2.cpp -o min2; echo "status $status"
fatal error: translation unit is too large for Clang to process:
ran out of source locations
clang++: error: clang frontend command failed with exit code 70 (use -v to see invocation)
clang version 21.1.8 (RESF 21.1.8-2.el9)
Target: x86_64-redhat-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Configuration file: /etc/clang/x86_64-redhat-linux-gnu-clang++.cfg
clang++: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang++: note: diagnostic msg: /tmp/min2-29d3f3.cpp
clang++: note: diagnostic msg: /tmp/min2-29d3f3.sh
clang++: note: diagnostic msg:

********************
105.029u 2.849s 1:48.32 99.5% 0+0k 32+1252520io 0pf+0w
status 1

time clang -S -emit-llvm -o min2.ll min2.cpp ; echo "status $status"
fatal error: translation unit is too large for Clang to process:
ran out of source locations
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: clang -S -emit-llvm -o min2.ll min2.cpp
1. min2.cpp:8529875:1: current parser token 'assert'
2. min2.cpp:7:1: parsing function body 'CGPengine::LoadRun'
3. min2.cpp:7:1: in compound statement ('{}')
#0 0x00007f187b1ccae9 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/lib64/libLLVM.so.21.1+0x4bccae9)
#1 0x00007f187b1cc859 llvm::sys::CleanupOnSignal(unsigned long) (/lib64/libLLVM.so.21.1+0x4bcc859)
#2 0x00007f187b13898e (/lib64/libLLVM.so.21.1+0x4b3898e)
#3 0x00007f187b13893f llvm::CrashRecoveryContext::HandleExit(int) (/lib64/libLLVM.so.21.1+0x4b3893f)
#4 0x00007f187b1c97ab llvm::sys::Process::Exit(int, bool) (/lib64/libLLVM.so.21.1+0x4bc97ab)
#5 0x000000000021bccf (/usr/bin/clang-21+0x21bccf)
#6 0x00007f187b146e3c llvm::report_fatal_error(llvm::Twine const&, bool) (/lib64/libLLVM.so.21.1+0x4b46e3c)
#7 0x00007f1879ec908b llvm::report_fatal_error(char const*, bool) (/lib64/libLLVM.so.21.1+0x38c908b)
#8 0x00007f187f78650a clang::TokenLexer::Init(clang::Token&, clang::SourceLocation, clang::MacroInfo*, clang::MacroArgs*) (/lib64/libclang-cpp.so.21.1+0x158650a)
#9 0x00007f187f77fcee clang::Preprocessor::HandleMacroExpandedIdentifier(clang::Token&, clang::MacroDefinition const&) (/lib64/libclang-cpp.so.21.1+0x157fcee)
#10 0x00007f187f77d3e5 clang::Preprocessor::HandleIdentifier(clang::Token&) (/lib64/libclang-cpp.so.21.1+0x157d3e5)
#11 0x00007f187f8c0706 clang::MacroArgs::getPreExpArgument(unsigned int, clang::Preprocessor&) (/lib64/libclang-cpp.so.21.1+0x16c0706)
#12 0x00007f187f785f2f clang::TokenLexer::Init(clang::Token&, clang::SourceLocation, clang::MacroInfo*, clang::MacroArgs*) (/lib64/libclang-cpp.so.21.1+0x1585f2f)
#13 0x00007f187f77fcee clang::Preprocessor::HandleMacroExpandedIdentifier(clang::Token&, clang::MacroDefinition const&) (/lib64/libclang-cpp.so.21.1+0x157fcee)
#14 0x00007f187f73f418 clang::Lexer::Lex(clang::Token&) (/lib64/libclang-cpp.so.21.1+0x153f418)
#15 0x00007f187f9017bf clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/lib64/libclang-cpp.so.21.1+0x17017bf)
#16 0x00007f187fc379ca clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/lib64/libclang-cpp.so.21.1+0x1a379ca)
#17 0x00007f187fe1f88d clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/lib64/libclang-cpp.so.21.1+0x1c1f88d)
#18 0x00007f187f9f964f clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/lib64/libclang-cpp.so.21.1+0x17f964f)
#19 0x00007f187f9f6369 clang::ParseAST(clang::Sema&, bool, bool) (/lib64/libclang-cpp.so.21.1+0x17f6369)
#20 0x00007f18803b05df clang::FrontendAction::Execute() (/lib64/libclang-cpp.so.21.1+0x21b05df)
#21 0x00007f18803afff5 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/lib64/libclang-cpp.so.21.1+0x21afff5)
#22 0x00007f18803af9a5 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/lib64/libclang-cpp.so.21.1+0x21af9a5)
#23 0x00000000002185e2 cc1_main(llvm::ArrayRef, char const*, void*) (/usr/bin/clang-21+0x2185e2)
#24 0x000000000020f88c (/usr/bin/clang-21+0x20f88c)
#25 0x00007f188193c14d (/lib64/libclang-cpp.so.21.1+0x373c14d)
#26 0x00007f187b13891b llvm::CrashRecoveryContext::RunSafely(llvm::function_ref) (/lib64/libLLVM.so.21.1+0x4b3891b)
#27 0x00007f18805c4765 clang::driver::CC1Command::Execute(llvm::ArrayRef>, std::__cxx11::basic_string, std::allocator>*, bool*) const (/lib64/libclang-cpp.so.21.1+0x23c4765)
#28 0x00007f188050c7fe clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/lib64/libclang-cpp.so.21.1+0x230c7fe)
#29 0x00007f188050c5f2 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl>&, bool) const (/lib64/libclang-cpp.so.21.1+0x230c5f2)
#30 0x00007f188050bf66 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl>&) (/lib64/libclang-cpp.so.21.1+0x230bf66)
#31 0x0000000000211de7 clang_main(int, char**, llvm::ToolContext const&) (/usr/bin/clang-21+0x211de7)
#32 0x00000000002106b2 main (/usr/bin/clang-21+0x2106b2)
#33 0x00007f1875e2a610 __libc_start_call_main (/lib64/libc.so.6+0x2a610)
#34 0x00007f1875e2a6c0 __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x2a6c0)
#35 0x000000000021ad85 _start (/usr/bin/clang-21+0x21ad85)
clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
clang version 21.1.8 (RESF 21.1.8-2.el9)
Target: x86_64-redhat-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Configuration file: /etc/clang/x86_64-redhat-linux-gnu-clang.cfg
clang: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/min2-7acc95.cpp
clang: note: diagnostic msg: /tmp/min2-7acc95.sh
clang: note: diagnostic msg:

********************
107.472u 2.869s 1:50.81 99.5% 0+0k 92480+1256976io 67pf+0w
status 1
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the failure with `clang -S -emit-llvm -o min2.ll min2.cpp` using the attached min2.cpp archive. Read the stack dump around clang::TokenLexer::Init, Preprocessor macro expansion, and Parser::ParseFunctionStatementBody. Done means establishing behavior for this 20,000,010-line translation unit without the reported source-location failure, with the result verified against the supplied command.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.