<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/116156>116156</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            clang-20 crashed with address sanitizer at -O1 and above. LLVM ERROR: out of memory Allocation failed
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          iamanonymouscs
      </td>
    </tr>
</table>

<pre>
    clang-20 crashed with ```address``` sanitizer at ```-O1``` and above. It does not crash at ```-O0```.

Compiler explorer: https://godbolt.org/z/4qqsjfsvY

```
$cat mutant.c
long a;
void c(int b[]);
void d() {
  a = __PTRDIFF_MAX__;
  int b[a];
  c(b);
}
```

Also crashed at Clang-19.

```
$clang-19 -fsanitize=address -O1 mutant.c
LLVM ERROR: out of memory
Allocation failed
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: /usr/lib/llvm-19/bin/clang -cc1 -triple x86_64-pc-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name mutant.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/home/code/InsertAttr -fcoverage-compilation-dir=/home/code/InsertAttr -resource-dir /usr/lib/llvm-19/lib/clang/19 -internal-isystem /usr/lib/llvm-19/lib/clang/19/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O1 -ferror-limit 19 -fsanitize=address -fsanitize-system-ignorelist=/usr/lib/llvm-19/lib/clang/19/share/asan_ignorelist.txt -fno-sanitize-memory-param-retval -fsanitize-address-use-after-scope -fsanitize-address-globals-dead-stripping -fno-assume-sane-operator-new -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/mutant-19ae9b.o -x c mutant.c
1. <eof> parser at end of file
2.      Optimizer
3.      Running pass "asan<>" on module "mutant.c"
 #0 0x00007ff6ee2a9246 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0xea7246)
 #1 0x00007ff6ee2a6e20 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0xea4e20)
 #2 0x00007ff6ee2a990b (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0xea790b)
 #3 0x00007ff6ecee1520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007ff6ecf359fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x00007ff6ecee1476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x00007ff6ecec77f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x00007ff6ee205084 llvm::report_bad_alloc_error(char const*, bool) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0xe03084)
 #8 0x00007ff6ee23edd9 (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0xe3cdd9)
 #9 0x00007ff6eee694a4 llvm::GetShadowBytes(llvm::SmallVectorImpl<llvm::ASanStackVariableDescription> const&, llvm::ASanStackFrameLayout const&) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0x1a674a4)
#10 0x00007ff6eee69569 llvm::GetShadowBytesAfterScope(llvm::SmallVectorImpl<llvm::ASanStackVariableDescription> const&, llvm::ASanStackFrameLayout const&) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0x1a67569)
#11 0x00007ff6eefe678b (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0x1be478b)
#12 0x00007ff6eefdd9e7 (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0x1bdb9e7)
#13 0x00007ff6eefd8b27 llvm::AddressSanitizerPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0x1bd6b27)
#14 0x00007ff6f6dc46ed (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.0+0x1e306ed)
#15 0x00007ff6ee42eb99 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0x102cb99)
#16 0x00007ff6f6dbc091 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.0+0x1e28091)
#17 0x00007ff6f6db493b clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.0+0x1e2093b)
#18 0x00007ff6f715a132 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.0+0x21c6132)
#19 0x00007ff6f5bc3739 clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.0+0xc2f739)
#20 0x00007ff6f7c560b5 clang::FrontendAction::Execute() (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.0+0x2cc20b5)
#21 0x00007ff6f7bc62f4 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.0+0x2c322f4)
#22 0x00007ff6f7cd2dee clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.0+0x2d3edee)
#23 0x000055c096af3bc5 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/lib/llvm-19/bin/clang+0x11bc5)
#24 0x000055c096af0ad5 (/usr/lib/llvm-19/bin/clang+0xead5)
#25 0x000055c096aefc9b clang_main(int, char**, llvm::ToolContext const&) (/usr/lib/llvm-19/bin/clang+0xdc9b)
#26 0x000055c096afdf36 main (/usr/lib/llvm-19/bin/clang+0x1bf36)
#27 0x00007ff6ecec8d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#28 0x00007ff6ecec8e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#29 0x000055c096aee765 _start (/usr/lib/llvm-19/bin/clang+0xc765)
clang: error: unable to execute command: Aborted (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
Ubuntu clang version 19.0.0 (++20240722031324+65825cd5431c-1~exp1~20240722151445.1819)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-19/bin
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/mutant-6e2461.c
clang: note: diagnostic msg: /tmp/mutant-6e2461.sh
clang: note: diagnostic msg: 

********************
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcWktz27iT_zT0BQUVCT4kHnyQJStxlbN2WZ78d08qEGhSmJAABwAVew7z2bdAUg_IdhJnfNhal0qWwEa_8UMDLWqMqCTAZZBeBenygnZ2q_SloA2VSj43qjPMXBSKP1-ymsoKkxAxTc0WOPou7BYFWTi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