godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.53k stars 21.08k forks source link

Linux - building from source with GCC giving different segfault errors, Clang also fails #81490

Closed ACDouble closed 5 months ago

ACDouble commented 1 year ago

Godot version

4.1.1

System information

Linux Mint 21

Issue description

Following the documentation https://docs.godotengine.org/en/latest/contributing/development/compiling/compiling_for_linuxbsd.html#doc-compiling-for-linuxbsd , I've installed all the recquired packages, cloned the repo and ran scons platform=linuxbsd

At first, everything was running smoothly, until I was hit with the following error:

[Initial build] Compiling thirdparty/glslang/glslang/MachineIndependent/intermOut.cpp ...
In file included from ./core/string/ustring.h:38,
                 from ./core/string/string_name.h:35,
                 from modules/gdscript/gdscript_utility_functions.h:34,
                 from modules/gdscript/gdscript_function.h:34,
                 from modules/gdscript/gdscript.h:34,
                 from modules/gdscript/gdscript_cache.h:34,
                 from modules/gdscript/gdscript_parser.h:34,
                 from modules/gdscript/gdscript_parser.cpp:31:
./core/templates/vector.h: In member function 'bool Vector<T>::push_back(T) [with T = GDScriptParser::IdentifierNode*]':
./core/templates/vector.h:321:1: internal compiler error: Segmentation fault
  321 | }
      | ^
0x7f97a290108f ???
    /build/glibc-SzIz7B/glibc-2.31/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0
0x7f97a28e2082 __libc_start_main
    ../csu/libc-start.c:308
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-9/README.Bugs> for instructions.
scons: *** [modules/gdscript/gdscript_parser.linuxbsd.editor.x86_64.o] Error 1
scons: building terminated because of errors.
[Time elapsed: 00:02:13.891]

I've opened the offending file, and this is how it was;

template <class T>
bool Vector<T>::push_back(T p_elem) {
    Error err = resize(size() + 1);
    ERR_FAIL_COND_V(err, true);
    set(size() - 1, p_elem);

    return false;
}

I've removed the empty line before the return and ran the scons again. This time, I got a segfault at a different place:

[Initial build] Compiling modules/gdscript/language_server/gdscript_extend_parser.cpp ...
In file included from ./core/variant/binder_common.h:35,
                 from ./core/object/method_bind.h:34,
                 from ./core/object/class_db.h:34,
                 from ./core/object/ref_counted.h:34,
                 from modules/gdscript/gdscript_function.h:36,
                 from modules/gdscript/gdscript.h:34,
                 from modules/gdscript/register_types.cpp:33:
./core/object/object.h:384:41: internal compiler error: Segmentation fault
  384 |  void operator=(const m_class &p_rval) {}                                                                                                     \
      |                                         ^
./scene/gui/rich_text_label.h:41:2: note: in expansion of macro 'GDCLASS'
   41 |  GDCLASS(RichTextLabel, Control);
      |  ^~~~~~~
0x7f88d28ec08f ???
    /build/glibc-SzIz7B/glibc-2.31/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0
0x7f88d28cd082 __libc_start_main
    ../csu/libc-start.c:308
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-9/README.Bugs> for instructions.
scons: *** [modules/gdscript/register_types.linuxbsd.editor.x86_64.o] Error 1
scons: building terminated because of errors.
[Time elapsed: 00:00:57.801]

Simply running the scons again, without doing any modifications to that /core/object/object.h, I was met with yet another segfault, this time pointing to /core/object/object.h:496

Running yet another time, without any modifications to the code, this showed up:

[Initial build] Compiling thirdparty/pcre2/src/pcre2_convert.c ...
{standard input}: Assembler messages:
{standard input}: Internal error (Segmentation fault).
Please report this bug.
scons: *** [thirdparty/embree/kernels/bvh/bvh_builder_sah_mb.linuxbsd.editor.x86_64.o] Error 1
scons: building terminated because of errors.
[Time elapsed: 00:01:47.614]

Since a cursory google search showed several posts and topics pointing to segfault errors with GCC unrelated to Godot, I've decided to run scons platform=linuxbsd use_llvm=yes to compile using Clang, as noted in an info box on the docs.

After roughly 8 minutes, with everything working fine thus far, the compilation failed with the following error

[Initial build] Compiling editor/register_editor_types.cpp ...
[Initial build] Compiling editor/rename_dialog.cpp ...
Stack dump:
0.  Program arguments: clang++ -o editor/editor_translation.linuxbsd.editor.x86_64.llvm.o -c -std=gnu++17 -pipe -O2 -fno-exceptions -Wall -Wshadow-field-in-constructor -Wshadow-uncaptured-local -Wno-ordered-compare-function-pointers -isystem thirdparty/glad -DTOOLS_ENABLED -DDEBUG_ENABLED -DNDEBUG -DNO_EDITOR_SPLASH -DSOWRAP_ENABLED -DTOUCH_ENABLED -DFONTCONFIG_ENABLED -DALSA_ENABLED -DALSAMIDI_ENABLED -DPULSEAUDIO_ENABLED -D_REENTRANT -DDBUS_ENABLED -DSPEECHD_ENABLED -DXKB_ENABLED -DJOYDEV_ENABLED -DUDEV_ENABLED -DLINUXBSD_ENABLED -DUNIX_ENABLED -D_FILE_OFFSET_BITS=64 -DX11_ENABLED -DVULKAN_ENABLED -DGLES3_ENABLED -DMINIZIP_ENABLED -DBROTLI_ENABLED -DZSTD_STATIC_LINKING_ONLY -DUSE_VOLK -DVK_USE_PLATFORM_XLIB_KHR -DGLAD_ENABLED -DGLES_OVER_GL -DGLAD_GLX_NO_X11 -DHAVE_MNTENT -Ithirdparty/freetype/include -Ithirdparty/libpng -Ithirdparty/volk -Ithirdparty/vulkan -Ithirdparty/vulkan/include -Ithirdparty/zstd -Ithirdparty/zlib -Ithirdparty/brotli/include -Ithirdparty/linuxbsd_headers -Iplatform/linuxbsd -I. editor/editor_translation.cpp 
1.  <eof> parser at end of file
2.  Per-file LLVM IR generation
3.  ./editor/doc_translations.gen.h:468451:28: Generating code for declaration '_doc_translation_zh_CN_compressed'
 #0 0x00007fb69c3384ff llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/lib/x86_64-linux-gnu/libLLVM-10.so.1+0x9814ff)
 #1 0x00007fb69c3367b0 llvm::sys::RunSignalHandlers() (/lib/x86_64-linux-gnu/libLLVM-10.so.1+0x97f7b0)
 #2 0x00007fb69c337c4d llvm::sys::CleanupOnSignal(unsigned long) (/lib/x86_64-linux-gnu/libLLVM-10.so.1+0x980c4d)
 #3 0x00007fb69c28de60 (/lib/x86_64-linux-gnu/libLLVM-10.so.1+0x8d6e60)
 #4 0x00007fb6a2b07420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #5 0x00007fb6a0c6e9db clang::Type::isLiteralType(clang::ASTContext const&) const (/lib/x86_64-linux-gnu/libclang-cpp.so.10+0xc239db)
 #6 0x00007fb6a0b39098 (/lib/x86_64-linux-gnu/libclang-cpp.so.10+0xaee098)
 #7 0x00007fb6a0ae415a (/lib/x86_64-linux-gnu/libclang-cpp.so.10+0xa9915a)
 #8 0x00007fb6a0b270d4 (/lib/x86_64-linux-gnu/libclang-cpp.so.10+0xadc0d4)
 #9 0x00007fb6a0ae41ca (/lib/x86_64-linux-gnu/libclang-cpp.so.10+0xa991ca)
#10 0x00007fb6a0ae3e1c clang::Expr::EvaluateAsInitializer(clang::APValue&, clang::ASTContext const&, clang::VarDecl const*, llvm::SmallVectorImpl<std::pair<clang::SourceLocation, clang::PartialDiagnostic> >&) const (/lib/x86_64-linux-gnu/libclang-cpp.so.10+0xa98e1c)
#11 0x00007fb6a0a7fe90 clang::VarDecl::evaluateValue(llvm::SmallVectorImpl<std::pair<clang::SourceLocation, clang::PartialDiagnostic> >&) const (/lib/x86_64-linux-gnu/libclang-cpp.so.10+0xa34e90)
#12 0x00007fb6a0a7fd40 clang::VarDecl::evaluateValue() const (/lib/x86_64-linux-gnu/libclang-cpp.so.10+0xa34d40)
#13 0x00007fb6a15704d4 clang::CodeGen::ConstantEmitter::tryEmitPrivateForVarInit(clang::VarDecl const&) (/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x15254d4)
#14 0x00007fb6a15717d0 clang::CodeGen::ConstantEmitter::tryEmitForInitializer(clang::VarDecl const&) (/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x15267d0)
#15 0x00007fb6a16d360f clang::CodeGen::CodeGenModule::EmitGlobalVarDefinition(clang::VarDecl const*, bool) (/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x168860f)
#16 0x00007fb6a16cce0b clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x1681e0b)
#17 0x00007fb6a16c3fb1 clang::CodeGen::CodeGenModule::EmitDeferred() (/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x1678fb1)
#18 0x00007fb6a16c3fcd clang::CodeGen::CodeGenModule::EmitDeferred() (/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x1678fcd)
#19 0x00007fb6a16c3337 clang::CodeGen::CodeGenModule::Release() (/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x1678337)
#20 0x00007fb6a1744ee4 (/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x16f9ee4)
#21 0x00007fb6a16b2b5d (/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x1667b5d)
#22 0x00007fb6a08a0c13 clang::ParseAST(clang::Sema&, bool, bool) (/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x855c13)
#23 0x00007fb6a1d16e58 clang::FrontendAction::Execute() (/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x1ccbe58)
#24 0x00007fb6a1ccf8a1 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x1c848a1)
#25 0x00007fb6a1d7adaf clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x1d2fdaf)
#26 0x000000000041229d cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/lib/llvm-10/bin/clang+0x41229d)
#27 0x00000000004105b1 (/usr/lib/llvm-10/bin/clang+0x4105b1)
#28 0x00007fb6a1a208f2 (/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x19d58f2)
#29 0x00007fb69c28dc67 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/lib/x86_64-linux-gnu/libLLVM-10.so.1+0x8d6c67)
#30 0x00007fb6a1a1fe2f clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const (/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x19d4e2f)
#31 0x00007fb6a19f852f clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x19ad52f)
#32 0x00007fb6a19f86da clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const (/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x19ad6da)
#33 0x00007fb6a1a0b93c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) (/lib/x86_64-linux-gnu/libclang-cpp.so.10+0x19c093c)
#34 0x000000000041002f main (/usr/lib/llvm-10/bin/clang+0x41002f)
#35 0x00007fb69b49b083 __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:342:3
#36 0x000000000040d7ce _start (/usr/lib/llvm-10/bin/clang+0x40d7ce)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 10.0.0-4ubuntu1 
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang: note: diagnostic msg: PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
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/editor_translation-068093.cpp
clang: note: diagnostic msg: /tmp/editor_translation-068093.sh
clang: note: diagnostic msg: 

********************
scons: *** [editor/editor_translation.linuxbsd.editor.x86_64.llvm.o] Error 254
scons: building terminated because of errors.
[Time elapsed: 00:08:31.330]

Running again, the error was different:

[Initial build] Compiling editor/plugins/gradient_texture_2d_editor_plugin.cpp ...
Stack dump:
0.  Program arguments: clang++ -o editor/plugins/font_config_plugin.linuxbsd.editor.x86_64.llvm.o -c -std=gnu++17 -pipe -O2 -fno-exceptions -Wall -Wshadow-field-in-constructor -Wshadow-uncaptured-local -Wno-ordered-compare-function-pointers -isystem thirdparty/glad -DTOOLS_ENABLED -DDEBUG_ENABLED -DNDEBUG -DNO_EDITOR_SPLASH -DSOWRAP_ENABLED -DTOUCH_ENABLED -DFONTCONFIG_ENABLED -DALSA_ENABLED -DALSAMIDI_ENABLED -DPULSEAUDIO_ENABLED -D_REENTRANT -DDBUS_ENABLED -DSPEECHD_ENABLED -DXKB_ENABLED -DJOYDEV_ENABLED -DUDEV_ENABLED -DLINUXBSD_ENABLED -DUNIX_ENABLED -D_FILE_OFFSET_BITS=64 -DX11_ENABLED -DVULKAN_ENABLED -DGLES3_ENABLED -DMINIZIP_ENABLED -DBROTLI_ENABLED -DZSTD_STATIC_LINKING_ONLY -DUSE_VOLK -DVK_USE_PLATFORM_XLIB_KHR -DGLAD_ENABLED -DGLES_OVER_GL -DGLAD_GLX_NO_X11 -DHAVE_MNTENT -Ithirdparty/freetype/include -Ithirdparty/libpng -Ithirdparty/volk -Ithirdparty/vulkan -Ithirdparty/vulkan/include -Ithirdparty/zstd -Ithirdparty/zlib -Ithirdparty/brotli/include -Ithirdparty/linuxbsd_headers -Iplatform/linuxbsd -I. editor/plugins/font_config_plugin.cpp 
1.  <eof> parser at end of file
2.  Code generation
3.  Running pass 'Function Pass Manager' on module 'editor/plugins/font_config_plugin.cpp'.
4.  Running pass 'Greedy Register Allocator' on function '@_ZN28EditorPropertyFontNamesArrayC2Ev'
#0 0x00007f58b4eca4ff llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/lib/x86_64-linux-gnu/libLLVM-10.so.1+0x9814ff)
#1 0x00007f58b4ec87b0 llvm::sys::RunSignalHandlers() (/lib/x86_64-linux-gnu/libLLVM-10.so.1+0x97f7b0)
#2 0x00007f58b4ec9c4d llvm::sys::CleanupOnSignal(unsigned long) (/lib/x86_64-linux-gnu/libLLVM-10.so.1+0x980c4d)
#3 0x00007f58b4e1fe60 (/lib/x86_64-linux-gnu/libLLVM-10.so.1+0x8d6e60)
#4 0x00007f58bb699420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#5 0x00007f58b453ac98 (/lib/x86_64-linux-gnu/libstdc++.so.6+0x1d3c98)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 10.0.0-4ubuntu1 
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang: note: diagnostic msg: PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
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/font_config_plugin-abdd14.cpp
clang: note: diagnostic msg: /tmp/font_config_plugin-abdd14.sh
clang: note: diagnostic msg: 

********************
scons: *** [editor/plugins/font_config_plugin.linuxbsd.editor.x86_64.llvm.o] Error 254
scons: building terminated because of errors.
[Time elapsed: 00:01:41.108]

Only added the first Clang failure files because I kept getting an error with Github trying to upload the second one

editor-translation.zip

Steps to reproduce

On Linux Mint 21:

Minimal reproduction project

N/A

kxn commented 1 year ago

internal compiler error at compiling often indicates unstable hardware. Please try on another computer

akien-mga commented 5 months ago

As pointed out by @kxn, this is likely a hardware failure. Linux Mint 21 seems to provide GCC 9 which is working fine otherwise in my tests (and many users compiling on Ubuntu 22.04 LTS), and it failing similar with Clang further confirms that it doesn't seem to be a compiler issue, but something specific to your hardware or system.

Closing as this isn't something we can solve in Godot.