llvm / llvm/llvm-project

Crash when compiling precompiled module file to object with mingw and debug

Open
#190,008 6 comments 0 reactions 0 assignees View on GitHub
crash llvm:codegen
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

The file compiles fine with target x86_64-pc-linux-gnu or if not using debug.

```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++ --target=x86_64-w64-mingw32 -march=native -mtune=native -std=c++26 -D CRAFTER_BUILD_CONFIGURATION_TARGET=\"x86_64_w64_mingw32\" -D CRAFTER_BUILD_CONFIGURATION_TARGET_x86_64_w64_mingw32 -fprebuilt-module-path=/home/jorijn/repos/Crafter/Crafter.Build/bin/x86_64-w64-mingw32native -I/home/jorijn/repos/Crafter/Crafter.Build/bin/cloneCache/Vulkan-Headers/include -I/home/jorijn/repos/Crafter/Crafter.Build/bin/cloneCache/Vulkan-Utility-Libraries/include -I/home/jorijn/repos/Crafter/Crafter.Build/bin/cloneCache/glslang/build/include -I/home/jorijn/repos/Crafter/Crafter.Build/bin/cloneCache/Crafter.Graphics -I/home/jorijn/repos/Crafter/Crafter.Build/bin/cloneCache/Vulkan-Headers -I/home/jorijn/repos/Crafter/Crafter.Build/bin/cloneCache/Vulkan-Utility-Libraries -I/home/jorijn/repos/Crafter/Crafter.Build/bin/cloneCache/Crafter.Event -I/home/jorijn/repos/Crafter/Crafter.Build/bin/cloneCache/Crafter.Math -I/home/jorijn/repos/Crafter/Crafter.Build/bin/cloneCache/Crafter.Asset -I/home/jorijn/repos/Crafter/Crafter.Build/bin/cloneCache/glslang -D CRAFTER_BUILD_CONFIGURATION_TYPE_EXECUTABLE -fprebuilt-module-path=/home/jorijn/repos/3DForts/build/executable-windows-gnu -g -D CRAFTER_BUILD_CONFIGURATION_DEBUG -Wno-unused-command-line-argument /home/jorijn/repos/3DForts/build/executable-windows-gnu/Forts3D-Brace.pcm -c -o /home/jorijn/repos/3DForts/build/executable-windows-gnu/Forts3D-Brace.o
1. parser at end of file
2. Code generation
#0 0x00007fa40a356aed llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /usr/src/debug/llvm/llvm-project-22.1.2.src/llvm/lib/Support/Unix/Signals.inc:842:22
#1 0x00007fa40a3545c7 llvm::sys::RunSignalHandlers() /usr/src/debug/llvm/llvm-project-22.1.2.src/llvm/lib/Support/Signals.cpp:108:20
#2 0x00007fa40a3545c7 llvm::sys::CleanupOnSignal(unsigned long) /usr/src/debug/llvm/llvm-project-22.1.2.src/llvm/lib/Support/Unix/Signals.inc:376:31
#3 0x00007fa40a21c9f9 HandleCrash /usr/src/debug/llvm/llvm-project-22.1.2.src/llvm/lib/Support/CrashRecoveryContext.cpp:73:5
#4 0x00007fa40a21c9f9 CrashRecoverySignalHandler /usr/src/debug/llvm/llvm-project-22.1.2.src/llvm/lib/Support/CrashRecoveryContext.cpp:390:62
#5 0x00007fa40944d2d0 (/usr/lib/libc.so.6+0x3e2d0)
#6 0x00007fa40a5ce4e3 stripPointerCastsAndOffsets<(::PointerStripKind)0> /usr/src/debug/llvm/llvm-project-22.1.2.src/llvm/lib/IR/Value.cpp:640:3
#7 0x00007fa40a5ce4e3 llvm::Value::stripPointerCasts() const /usr/src/debug/llvm/llvm-project-22.1.2.src/llvm/lib/IR/Value.cpp:709:54
#8 0x00007fa40b1a5886 llvm::GlobalValue::classof(llvm::Value const*) /usr/src/debug/llvm/llvm-project-22.1.2.src/llvm/include/llvm/IR/GlobalValue.h:675:53
#9 0x00007fa40b1a5886 llvm::isa_impl::doit(llvm::Constant const&) /usr/src/debug/llvm/llvm-project-22.1.2.src/llvm/include/llvm/Support/Casting.h:64:64
#10 0x00007fa40b1a5886 llvm::isa_impl_cl::doit(llvm::Constant const*) /usr/src/debug/llvm/llvm-project-22.1.2.src/llvm/include/llvm/Support/Casting.h:110:36
#11 0x00007fa40b1a5886 llvm::isa_impl_wrap::doit(llvm::Constant const* const&) /usr/src/debug/llvm/llvm-project-22.1.2.src/llvm/include/llvm/Support/Casting.h:137:41
#12 0x00007fa40b1a5886 llvm::isa_impl_wrap::doit(llvm::Constant* const&) /usr/src/debug/llvm/llvm-project-22.1.2.src/llvm/include/llvm/Support/Casting.h:129:13
#13 0x00007fa40b1a5886 llvm::CastIsPossible::isPossible(llvm::Constant* const&) /usr/src/debug/llvm/llvm-project-22.1.2.src/llvm/include/llvm/Support/Casting.h:257:62
#14 0x00007fa40b1a5886 llvm::CastInfo::doCastIfPossible(llvm::Constant* const&) /usr/src/debug/llvm/llvm-project-22.1.2.src/llvm/include/llvm/Support/Casting.h:493:26
#15 0x00007fa40b1a5886 decltype(auto) llvm::dyn_cast(llvm::Constant*) /usr/src/debug/llvm/llvm-project-22.1.2.src/llvm/include/llvm/Support/Casting.h:657:48
#16 0x00007fa40b1a5886 llvm::AsmPrinter::preprocessXXStructorList(llvm::DataLayout const&, llvm::Constant const*, llvm::SmallVector&) /usr/src/debug/llvm/llvm-project-22.1.2.src/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:3513:32
#17 0x00007fa40b1b98e9 llvm::SmallVectorBase::empty() const /usr/src/debug/llvm/llvm-project-22.1.2.src/llvm/include/llvm/ADT/SmallVector.h:83:46
#18 0x00007fa40b1b98e9 llvm::AsmPrinter::emitXXStructorList(llvm::DataLayout const&, llvm::Constant const*, bool) /usr/src/debug/llvm/llvm-project-22.1.2.src/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:3529:22
#19 0x00007fa40b1bda6b llvm::AsmPrinter::emitSpecialLLVMGlobal(llvm::GlobalVariable const*) /usr/src/debug/llvm/llvm-project-22.1.2.src/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:3462:23
#20 0x00007fa40b1bdc7d llvm::AsmPrinter::emitGlobalVariable(llvm::GlobalVariable const*) /usr/src/debug/llvm/llvm-project-22.1.2.src/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:765:5
#21 0x00007fa40b1b0c28 llvm::ilist_detail::node_base_prevnext, false>::getNext() const /usr/src/debug/llvm/llvm-project-22.1.2.src/llvm/include/llvm/ADT/ilist_node_base.h:28:38
#22 0x00007fa40b1b0c28 llvm::ilist_node_impl>::getNext() /usr/src/debug/llvm/llvm-project-22.1.2.src/llvm/include/llvm/ADT/ilist_node.h:108:66
#23 0x00007fa40b1b0c28 llvm::ilist_iterator, false, false>::operator++() /usr/src/debug/llvm/llvm-project-22.1.2.src/llvm/include/llvm/ADT/ilist_iterator.h:187:25
#24 0x00007fa40b1b0c28 llvm::AsmPrinter::doFinalization(llvm::Module&) /usr/src/debug/llvm/llvm-project-22.1.2.src/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:2768:34
#25 0x00007fa40a5325ad llvm::FPPassManager::doFinalization(llvm::Module&) /usr/src/debug/llvm/llvm-project-22.1.2.src/llvm/lib/IR/LegacyPassManager.cpp:1462:13
#26 0x00007fa40a53d839 runOnModule /usr/src/debug/llvm/llvm-project-22.1.2.src/llvm/lib/IR/LegacyPassManager.cpp:1549:13
#27 0x00007fa40a53d839 llvm::legacy::PassManagerImpl::run(llvm::Module&) /usr/src/debug/llvm/llvm-project-22.1.2.src/llvm/lib/IR/LegacyPassManager.cpp:531:55
#28 0x00007fa415d7b6cf RunCodegenPipeline /usr/src/debug/clang/llvm-project-22.1.2.src/clang/lib/CodeGen/BackendUtil.cpp:1278:9
#29 0x00007fa415d7b6cf emitAssembly /usr/src/debug/clang/llvm-project-22.1.2.src/clang/lib/CodeGen/BackendUtil.cpp:1301:21
#30 0x00007fa415d7bc4d std::unique_ptr>::~unique_ptr() /usr/include/c++/15.2.1/bits/unique_ptr.h:397:2
#31 0x00007fa415d7bc4d clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr, std::unique_ptr>, clang::BackendConsumer*) /usr/src/debug/clang/llvm-project-22.1.2.src/clang/lib/CodeGen/BackendUtil.cpp:1473:25
#32 0x00007fa416184025 llvm::IntrusiveRefCntPtr::release() /usr/include/llvm/ADT/IntrusiveRefCntPtr.h:232:9
#33 0x00007fa416184025 llvm::IntrusiveRefCntPtr::~IntrusiveRefCntPtr() /usr/include/llvm/ADT/IntrusiveRefCntPtr.h:196:34
#34 0x00007fa416184025 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) /usr/src/debug/clang/llvm-project-22.1.2.src/clang/lib/CodeGen/CodeGenAction.cpp:310:20
#35 0x00007fa4144dacb4 clang::ParseAST(clang::Sema&, bool, bool) /usr/src/debug/clang/llvm-project-22.1.2.src/clang/lib/Parse/ParseAST.cpp:183:34
#36 0x00007fa416c0d9ac clang::FrontendAction::Execute() /usr/src/debug/clang/llvm-project-22.1.2.src/clang/lib/Frontend/FrontendAction.cpp:1317:38
#37 0x00007fa416b7b8c1 llvm::Error::getPtr() const /usr/include/llvm/Support/Error.h:281:12
#38 0x00007fa416b7b8c1 llvm::Error::operator bool() /usr/include/llvm/Support/Error.h:241:22
#39 0x00007fa416b7b8c1 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /usr/src/debug/clang/llvm-project-22.1.2.src/clang/lib/Frontend/CompilerInstance.cpp:1006:42
#40 0x00007fa416cc86b0 std::__shared_ptr::get() const /usr/include/c++/15.2.1/bits/shared_ptr_base.h:1673:16
#41 0x00007fa416cc86b0 std::__shared_ptr_access::_M_get() const /usr/include/c++/15.2.1/bits/shared_ptr_base.h:1370:69
#42 0x00007fa416cc86b0 std::__shared_ptr_access::operator*() const /usr/include/c++/15.2.1/bits/shared_ptr_base.h:1358:40
#43 0x00007fa416cc86b0 clang::CompilerInvocation::getFrontendOpts() /usr/src/debug/clang/llvm-project-22.1.2.src/clang/include/clang/Frontend/CompilerInvocation.h:277:48
#44 0x00007fa416cc86b0 clang::CompilerInstance::getFrontendOpts() /usr/src/debug/clang/llvm-project-22.1.2.src/clang/include/clang/Frontend/CompilerInstance.h:301:39
#45 0x00007fa416cc86b0 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /usr/src/debug/clang/llvm-project-22.1.2.src/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:311:29
#46 0x0000559181815f98 cc1_main(llvm::ArrayRef, char const*, void*) /usr/src/debug/clang/llvm-project-22.1.2.src/clang/tools/driver/cc1_main.cpp:304:40
#47 0x000055918180c8d1 ExecuteCC1Tool /usr/src/debug/clang/llvm-project-22.1.2.src/clang/tools/driver/driver.cpp:226:20
#48 0x000055918180ca9c std::__atomic_base::fetch_sub(int, std::memory_order) /usr/include/c++/15.2.1/bits/atomic_base.h:641:34
#49 0x000055918180ca9c llvm::ThreadSafeRefCountedBase::Release() const /usr/include/llvm/ADT/IntrusiveRefCntPtr.h:134:41
#50 0x000055918180ca9c llvm::IntrusiveRefCntPtrInfo::release(llvm::vfs::FileSystem*) /usr/include/llvm/ADT/IntrusiveRefCntPtr.h:164:45
#51 0x000055918180ca9c llvm::IntrusiveRefCntPtr::release() /usr/include/llvm/ADT/IntrusiveRefCntPtr.h:233:41
#52 0x000055918180ca9c llvm::IntrusiveRefCntPtr::~IntrusiveRefCntPtr() /usr/include/llvm/ADT/IntrusiveRefCntPtr.h:196:34
#53 0x000055918180ca9c operator() /usr/src/debug/clang/llvm-project-22.1.2.src/clang/tools/driver/driver.cpp:376:26
#54 0x000055918180ca9c callback_fn&)> > /usr/include/llvm/ADT/STLFunctionalExtras.h:46:52
#55 0x00007fa416720825 operator() /usr/src/debug/clang/llvm-project-22.1.2.src/clang/lib/Driver/Job.cpp:442:32
#56 0x00007fa416720825 callback_fn >, std::string*, bool*) const:: > /usr/include/llvm/ADT/STLFunctionalExtras.h:46:52
#57 0x00007fa40a21ce38 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref) /usr/src/debug/llvm/llvm-project-22.1.2.src/llvm/lib/Support/CrashRecoveryContext.cpp:428:1
#58 0x00007fa416721265 clang::driver::CC1Command::Execute(llvm::ArrayRef>, std::__cxx11::basic_string, std::allocator>*, bool*) const /usr/src/debug/clang/llvm-project-22.1.2.src/clang/lib/Driver/Job.cpp:446:10
#59 0x00007fa4166d2e9a clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const /usr/src/debug/clang/llvm-project-22.1.2.src/clang/lib/Driver/Compilation.cpp:196:22
#60 0x00007fa4166d3e0c clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl>&, bool) const /usr/src/debug/clang/llvm-project-22.1.2.src/clang/lib/Driver/Compilation.cpp:246:5
#61 0x00007fa4166ec8d6 llvm::SmallVectorBase::empty() const /usr/include/llvm/ADT/SmallVector.h:83:46
#62 0x00007fa4166ec8d6 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl>&) /usr/src/debug/clang/llvm-project-22.1.2.src/clang/lib/Driver/Driver.cpp:2265:28
#63 0x0000559181811c07 llvm::SmallVectorBase::size() const /usr/include/llvm/ADT/SmallVector.h:80:32
#64 0x0000559181811c07 llvm::SmallVectorTemplateCommon, void>::end() /usr/include/llvm/ADT/SmallVector.h:275:41
#65 0x0000559181811c07 clang_main(int, char**, llvm::ToolContext const&) /usr/src/debug/clang/llvm-project-22.1.2.src/clang/tools/driver/driver.cpp:416:26
#66 0x000055918180c0c0 main /usr/src/debug/clang/llvm-project-22.1.2.src/clang/build/tools/driver/clang-driver.cpp:18:1
#67 0x00007fa4094366c1 __libc_start_call_main /usr/src/debug/glibc/glibc/csu/../sysdeps/nptl/libc_start_call_main.h:83:3
#68 0x00007fa4094367f9 call_init /usr/src/debug/glibc/glibc/csu/../csu/libc-start.c:128:20
#69 0x00007fa4094367f9 __libc_start_main /usr/src/debug/glibc/glibc/csu/../csu/libc-start.c:347:5
#70 0x000055918180c125 _start (/usr/bin/clang+++0xc125)
clang++: error: clang frontend command failed with exit code 139 (use -v to see invocation)
clang version 22.1.2
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: /usr/bin
clang++: note: diagnostic msg: Error generating preprocessed source(s) - no preprocessable inputs.
```

the file in question:

```c++
module;
#include
export module Forts3D:Brace;
import Crafter.Graphics;
import Crafter.Math;
import std;
import :FortsTypes;
using namespace Crafter;

export namespace Forts3D {
class Node;
class Brace {
public:
RenderingElement3D renderer;
Node* origin;
Node* target;

Vector size;
Vector position;
Vector rotation;
MatrixRowMajor transform;

float ogLenght;

BraceGameData data;

std::uint16_t braceIndex;
std::uint32_t assetIndex;

Brace(Node* origin, Node* target, BraceLoadedData* data);
Brace(Brace&) = delete;
void UpdatePosition();

inline static std::vector braces;
inline static VulkanBuffer stressBuffer[Window::numFrames];

void Build();
void BuildGhost();
void Destroy();
void DestroyGhost();
void DestroyFromNode(Node* node);
void ApplyDamage(float damage);

static void UpdateBraceBuffer(Window& window);
static void Initalize(VkCommandBuffer cmd);
inline static std::uint16_t oldBraceSize = 1;
};
}
```

command that does work:
```
clang++ --target=x86_64-w64-mingw32 -march=native -mtune=native -std=c++26 -D CRAFTER_BUILD_CONFIGURATION_TARGET=\"x86_64_w64_mingw32\" -D CRAFTER_BUILD_CONFIGURATION_TARGET_x86_64_w64_mingw32 -fprebuilt-module-path=/home/jorijn/repos/Crafter/Crafter.Build/bin/x86_64-w64-mingw32native -I/home/jorijn/repos/Crafter/Crafter.Build/bin/cloneCache/Vulkan-Headers/include -I/home/jorijn/repos/Crafter/Crafter.Build/bin/cloneCache/Vulkan-Utility-Libraries/include -I/home/jorijn/repos/Crafter/Crafter.Build/bin/cloneCache/glslang/build/include -I/home/jorijn/repos/Crafter/Crafter.Build/bin/cloneCache/Crafter.Graphics -I/home/jorijn/repos/Crafter/Crafter.Build/bin/cloneCache/Vulkan-Headers -I/home/jorijn/repos/Crafter/Crafter.Build/bin/cloneCache/Vulkan-Utility-Libraries -I/home/jorijn/repos/Crafter/Crafter.Build/bin/cloneCache/Crafter.Event -I/home/jorijn/repos/Crafter/Crafter.Build/bin/cloneCache/Crafter.Math -I/home/jorijn/repos/Crafter/Crafter.Build/bin/cloneCache/Crafter.Asset -I/home/jorijn/repos/Crafter/Crafter.Build/bin/cloneCache/glslang -D CRAFTER_BUILD_CONFIGURATION_TYPE_EXECUTABLE -fprebuilt-module-path=/home/jorijn/repos/3DForts/build/executable-windows-gnu -O3 -Wno-unused-command-line-argument /home/jorijn/repos/3DForts/build/executable-windows-gnu/Forts3D-Brace.pcm -c -o /home/jorijn/repos/3DForts/build/executable-windows-gnu/Forts3D-Brace.o
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the reported clang++ command using the precompiled Forts3D-Brace.pcm input and compare the debug MinGW case with the working Linux or non-debug variants. Start in llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp around preprocessXXStructorList and review the Value.cpp stack frame. Done means the reported compilation no longer crashes and the differing configuration is covered by an appropriate regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.