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

    <tr>
        <th>Summary</th>
        <td>
            Clang-17.0.6 internal assembler crash compiling Wine-9.0-rc4 in 32bit i586
        </td>
    </tr>

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

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

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

<pre>
    Compiling wine-9.0-rc4 from source under 32bit chroot caused the following error when compiling the shell32.dll library:

```
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/bin/clang.bin --driver-mode=gcc -target i686-windows -Wno-unused-command-line-argument -fuse-ld=lld --no-default-config -xassembler -c -o tmp659d3f44/shell32-00000000.spec.o tmp659d3f45/shell32-00000000.spec-00000000.s
 #0 0xf0e3b98b llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/bin/../lib/libLLVM-17.so+0x2b3298b)
 #1 0xf0e3bf30 (/usr/bin/../lib/libLLVM-17.so+0x2b32f30)
 #2 0xf0e3960e llvm::sys::RunSignalHandlers() (/usr/bin/../lib/libLLVM-17.so+0x2b3060e)
 #3 0xf0e3ad8a llvm::sys::CleanupOnSignal(unsigned int) (/usr/bin/../lib/libLLVM-17.so+0x2b31d8a)
 #4 0xf0d7b0d0 (/usr/bin/../lib/libLLVM-17.so+0x2a720d0)
 #5 0xf7f05580 (linux-gate.so.1+0x580)
 #6 0xedd85625 pthread_kill@@GLIBC_2.34 (/lib/libc.so.6+0x9b625)
 #7 0xedd2a727 gsignal (/lib/libc.so.6+0x40727)
 #8 0xedd0c223 abort (/lib/libc.so.6+0x22223)
 #9 0xf0d8c0ec llvm::report_bad_alloc_error(char const*, bool) (/usr/bin/../lib/libLLVM-17.so+0x2a830ec)
#10 0xf0d8c161 (/usr/bin/../lib/libLLVM-17.so+0x2a83161)
#11 0xee13d87a operator new(unsigned int) (/usr/bin/../lib/libstdc++.so.6+0x9b87a)
#12 0xee13d8b4 operator new(unsigned int, std::nothrow_t const&) (/usr/bin/../lib/libstdc++.so.6+0x9b8b4)
#13 0xf0dae58c llvm::WritableMemoryBuffer::getNewUninitMemBuffer(unsigned int, llvm::Twine const&, std::optional<llvm::Align>) (/usr/bin/../lib/libLLVM-17.so+0x2aa558c)
#14 0xf0daedc1 (/usr/bin/../lib/libLLVM-17.so+0x2aa5dc1)
#15 0xf0dade3d (/usr/bin/../lib/libLLVM-17.so+0x2aa4e3d)
#16 0xf0dadd18 llvm::MemoryBuffer::getFile(llvm::Twine const&, bool, bool, bool, std::optional<llvm::Align>) (/usr/bin/../lib/libLLVM-17.so+0x2aa4d18)
#17 0xf0dce509 llvm::SourceMgr::OpenIncludeFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&) (/usr/bin/../lib/libLLVM-17.so+0x2ac5509)
#18 0xf0dce3e9 llvm::SourceMgr::AddIncludeFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, llvm::SMLoc, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&) (/usr/bin/../lib/libLLVM-17.so+0x2ac53e9)
#19 0xf27cc7b6 (/usr/bin/../lib/libLLVM-17.so+0x44c37b6)
#20 0xf27c88cf (/usr/bin/../lib/libLLVM-17.so+0x44bf8cf)
#21 0xf27c0f54 (/usr/bin/../lib/libLLVM-17.so+0x44b7f54)
#22 0x565fc2a8 cc1as_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/bin/clang.bin+0x1b2a8)
#23 0x565f3058 (/usr/bin/clang.bin+0x12058)
#24 0x565f488d (/usr/bin/clang.bin+0x1388d)
#25 0xf707a338 (/usr/bin/../lib/libclang-cpp.so.17+0x33a0338)
#26 0xf0d7ae2e llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/usr/bin/../lib/libLLVM-17.so+0x2a71e2e)
#27 0xf7079cfe clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (/usr/bin/../lib/libclang-cpp.so.17+0x339fcfe)
#28 0xf703d7b1 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/usr/bin/../lib/libclang-cpp.so.17+0x33637b1)
#29 0xf703d9e9 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/usr/bin/../lib/libclang-cpp.so.17+0x33639e9)
#30 0xf705b94f clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/usr/bin/../lib/libclang-cpp.so.17+0x338194f)
#31 0x565f2428 clang_main(int, char**, llvm::ToolContext const&) (/usr/bin/clang.bin+0x11428)
#32 0x56600a8a main (/usr/bin/clang.bin+0x1fa8a)
#33 0xedd0db12 __libc_start_call_main (/lib/libc.so.6+0x23b12)
#34 0xedd0dbe3 __libc_start_main@GLIBC_2.0 (/lib/libc.so.6+0x23be3)
#35 0x565eef27 _start (/usr/bin/clang.bin+0xdf27)
clang: error: clang integrated assembler command failed with exit code 134 (use -v to see invocation)
clang version 17.0.6
Target: i686-unknown-windows-msvc
Thread model: posix
InstalledDir: /usr/bin
clang: note: diagnostic msg: Error generating preprocessed source(s) - no preprocessable inputs.

```
I managed to extract the temporary files been used for this compilation and I'm attaching archive containing them, together with the exact command that reproduces the issue.

I'm running Slackware-current (under 32bit chroot), glibc-2.38 with system LLVM-17.0.6 .

I was able to compile the same file using the 64bit clang (also 17.0.6).

I repeated the 32bit compilation failure when making sure that there are more than 4GB free memory (that's separate from buffer/cached that could rapidly be freed by the kernel when needed).

I do suspect that the error might be related to ".incbin " directives that includes a huge number of small bits from another binary file. When first preparing the report, compilation required "dlls/shell32/shell32.res" file to reach the crash.
When (successfully) compiling with 64 bit clang, it asked for 3 more .res files in "dlls/shell32/i386-windows/*.res" .
I've included empty files with the same size, as 4MB archive seems to be too big to upload here and the empty files still reproduces the issue.

[report.clang.wine.ice.2024.01.09.v2.tar.gz](https://github.com/llvm/llvm-project/files/13875383/report.clang.wine.ice.2024.01.09.v2.tar.gz)

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUWd1z5CYS_2vkF0oqCfT54Ad_5ja1e0llc9nHKQQtDWcEc4A8dv76K0DjGa0_Nuvcpe62tjwzEvy6-9dNNzTUWjEqgPOkukyq6zM6u60250Lck7Ne88fzKz3thBRqRHuhIO2yPDWsRIPRE7J6NgzQrDgYRHAvHGJbo7VDjM4WOHJbQIOWUu89ABijDdpvQSH2hOqH2C1ISXDGpURS9Iaax4RcJPl1kh_-1vnyP_y8kFIz6oRWaKBCAo-Pf_54c_H5Btm5n4RDFPXziAzstHHIabR1bmc9Lr5N8O0o3HbuM6anBN9KeX_4SHdG_xOYS_CtsHYGm-BbRBVHQjE5cwgKM0PtFvWU3TlDGST4Cu0M7IxmYL3dkRj_2M-k1momqAOOzKyQZUbsXBZV_uwou0N8nnZPFucZ-tno0dAJUTPOEyjn1UYJvp2tSfBtL1SCb5mkasx6oVCaciPuwaST5pCQ65ExlDpqRnBI1G2d7oXiem9R-kXpdFbeNSnT00QVT6X36kEOSofZQip5Qq6l5ChNlU45DHSWLmVaDWJE6QO1FqZegkEpQ6lGbtrVVcfJUJYJvl2cmebLv8zugGWno6rXRp38ilSgBJMc5Q9DDqTv2h4FR5GLhFzYRxu__GyEcoHGX6Mv2uMgQ_cbbZ0BOiW49v4QyiW4Qwluv6Izy3wAiD7-_fjxt09p0WRWJ_gyf8A9wV3bJ7g76lUc9BpI_h68geQrPLzgdXUOL9n5y6w-i1FR-TequARjg8z3mJLXO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