Native Linux UE 4.15 crash when quitting Editor

Hi, I have been using native Linux build of UE 4.14 on Ubuntu 14.04.

I am trying to upgrade my project to UE 4.15, but even the clean Unreal Engine 4.15 keeps crashing on my system when I quit the editor.

I cloned and built EpicGames/UnrealEngine repository, and just ran UE4Editor (as described in https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Build/BatchFiles/Linux/README.md) and closed the initial project selection dialog. Then it crashed in FOpenGLDynamicRHI::Shutdown()

[2017.03.02-11.08.17:066][551]Cmd: QUIT_EDITOR
[2017.03.02-11.08.17:108][551]LogALAudio: Closing ALAudio device : OpenAL Soft
[2017.03.02-11.08.17:150][551]LogExit: Preparing to exit.
[2017.03.02-11.08.17:444][551]LogExit: Editor shut down
[2017.03.02-11.08.17:444][551]LogTemp:Display: Removed shader map 0x00007F57906F3C00 from material 0x00007F5797648200
[2017.03.02-11.08.17:444][551]LogTemp:Display: Removed shader map 0x00007F57906F3880 from material 0x00007F579072AA80
[2017.03.02-11.08.17:444][551]LogTemp:Display: Removed shader map 0x00007F5787235C00 from material 0x00007F579072BB00
[2017.03.02-11.08.17:444][551]LogTemp:Display: Removed shader map 0x00007F5787234E00 from material 0x00007F5787132C00
[2017.03.02-11.08.17:444][551]LogTemp:Display: Removed shader map 0x00007F57866CAB00 from material 0x00007F57866B9C80
[2017.03.02-11.08.17:444][551]LogTemp:Display: Removed shader map 0x00007F57866C6500 from material 0x00007F57862DFD00
[2017.03.02-11.08.17:444][551]LogTemp:Display: Removed shader map 0x00007F5786203E80 from material 0x00007F57862DA480
[2017.03.02-11.08.17:445][551]LogTemp:Display: Removed shader map 0x00007F57861FF880 from material 0x00007F57862D4900
[2017.03.02-11.08.17:445][551]LogTemp:Display: Removed shader map 0x00007F57861FB600 from material 0x00007F5785F89280
[2017.03.02-11.08.17:445][551]LogTemp:Display: Removed shader map 0x00007F57861F9A00 from material 0x00007F5785F86A00
[2017.03.02-11.08.17:445][551]LogTemp:Display: Removed shader map 0x00007F5785DAC580 from material 0x00007F5785F7F500
[2017.03.02-11.08.17:445][551]LogTemp:Display: Removed shader map 0x00007F5784CC3B80 from material 0x00007F5784FF0080
[2017.03.02-11.08.17:445][551]LogTemp:Display: Removed shader map 0x00007F5784CBEB00 from material 0x00007F5784BD9580
[2017.03.02-11.08.17:445][551]LogTemp:Display: Removed shader map 0x00007F5784CB9000 from material 0x00007F5784814780
[2017.03.02-11.08.17:445][551]LogTemp:Display: Removed shader map 0x00007F5784800D00 from material 0x00007F578480E780
[2017.03.02-11.08.17:445][551]LogTemp:Display: Removed shader map 0x00007F57847FB900 from material 0x00007F5784808900
[2017.03.02-11.08.17:445][551]LogTemp:Display: Removed shader map 0x00007F578388F880 from material 0x00007F5783907700
[2017.03.02-11.08.17:446][551]LogExit: Transaction tracking system shut down
[2017.03.02-11.08.17:446][551]LogTemp:Display: Removed shader map 0x00007F57E13EE000 from material 0x00007F5803C8D080
[2017.03.02-11.08.17:446][551]LogTemp:Display: Removed shader map 0x00007F58184E3500 from material 0x00007F57E1708F00
[2017.03.02-11.08.17:446][551]LogTemp:Display: Removed shader map 0x00007F58184DEB80 from material 0x00007F57DE913680
[2017.03.02-11.08.17:446][551]LogTemp:Display: Removed shader map 0x00007F57CEA3C700 from material 0x00007F57CE9C2E00
[2017.03.02-11.08.17:446][551]LogTemp:Display: Removed shader map 0x00007F57CEA38480 from material 0x00007F57CD8BEE80
[2017.03.02-11.08.17:446][551]LogTemp:Display: Removed shader map 0x00007F57CEA33080 from material 0x00007F57C64B9C80
[2017.03.02-11.08.17:446][551]LogTemp:Display: Removed shader map 0x00007F57B35E3200 from material 0x00007F57A32CD680
[2017.03.02-11.08.17:446][551]LogTemp:Display: Removed shader map 0x00007F57B35DE180 from material 0x00007F57835E8E00
[2017.03.02-11.08.17:446][551]LogTemp:Display: Removed shader map 0x00007F57B35DA280 from material 0x00007F576ACE9A80
[2017.03.02-11.08.17:446][551]LogTemp:Display: Removed shader map 0x00007F57CEA33780 from material 0x00007F57850F7D80
[2017.03.02-11.08.17:446][551]LogTemp:Display: Removed shader map 0x00007F576AAD9000 from material 0x00007F57850FE200
[2017.03.02-11.08.17:543][551]LogObj: Freed 0b from 0 cluster array pools.
[2017.03.02-11.08.17:544][551]LogExit: Object subsystem successfully closed.
[2017.03.02-11.08.17:544][551]LogHAL:Warning: Process (pid=3012) is still running - we will reap it in a waiter thread, but the thread handle is going to be leaked.
[2017.03.02-11.08.17:545][551]LogHAL:Warning: Process (pid=3013) is still running - we will reap it in a waiter thread, but the thread handle is going to be leaked.
[2017.03.02-11.08.17:545][551]LogHAL:Warning: Process (pid=3014) is still running - we will reap it in a waiter thread, but the thread handle is going to be leaked.
[2017.03.02-11.08.17:545][551]LogHAL:Warning: Process (pid=3015) is still running - we will reap it in a waiter thread, but the thread handle is going to be leaked.
[2017.03.02-11.08.17:545][551]LogHAL:Warning: Process (pid=3016) is still running - we will reap it in a waiter thread, but the thread handle is going to be leaked.
[2017.03.02-11.08.17:545][551]LogHAL:Warning: Process (pid=3017) is still running - we will reap it in a waiter thread, but the thread handle is going to be leaked.
[2017.03.02-11.08.17:545][551]LogHAL:Warning: Process (pid=3018) is still running - we will reap it in a waiter thread, but the thread handle is going to be leaked.
[2017.03.02-11.08.17:545][551]LogHAL:Warning: Process (pid=3019) is still running - we will reap it in a waiter thread, but the thread handle is going to be leaked.
[2017.03.02-11.08.17:618][551]LogCrashTracker:


[2017.03.02-11.08.17:618][551]LogLinux: === Critical error: ===
Unhandled Exception: SIGABRT: abort() called

[2017.03.02-11.08.17:618][551]LogLinux: Fatal error!

[Callstack]  00  0x00007f587ac55cdf  FLinuxPlatformStackWalk::CaptureStackBackTrace(unsigned long long*, unsigned int, void*)
[Callstack]  01  0x00007f587ab391a6  FGenericPlatformStackWalk::StackWalkAndDump(char*, unsigned long, int, void*)
[Callstack]  02  0x00007f587ac16a92  FLinuxCrashContext::CaptureStackTrace()
[Callstack]  03  0x00007f5870c962a0  CommonLinuxCrashHandler(FGenericCrashContext const&)
[Callstack]  04  0x00007f587ac1b155  PlatformCrashHandler(int, siginfo_t*, void*)
[Callstack]  05  0x00007f5880934330  /lib/x86_64-linux-gnu/libpthread.so.0(+0x10330) [0x7f5880934330]
[Callstack]  06  0x00007f58706fdc37  /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x37) [0x7f58706fdc37]
[Callstack]  07  0x00007f5870701028  /lib/x86_64-linux-gnu/libc.so.6(abort+0x148) [0x7f5870701028]
[Callstack]  08  0x00007f587073a2a4  /lib/x86_64-linux-gnu/libc.so.6(+0x732a4) [0x7f587073a2a4]
[Callstack]  09  0x00007f587074655e  /lib/x86_64-linux-gnu/libc.so.6(+0x7f55e) [0x7f587074655e]
[Callstack]  10  0x00007f5854e23753  FOpenGLRHIState::CleanupResources()
[Callstack]  11  0x00007f5854e1eb4f  FOpenGLDynamicRHI::Cleanup()
[Callstack]  12  0x00007f5854e1e930  FOpenGLDynamicRHI::Shutdown()
[Callstack]  13  0x00007f5874b53ce2  RHIExit()
[Callstack]  14  0x00000000004257dc  FEngineLoop::Exit() [/home/chonhyon/project/test/UnrealEngine/Engine/Source/Runtime/Launch/Private/LaunchEngineLoop.cpp, line 319]
[Callstack]  15  0x0000000000425c92  GuardedMain(wchar_t const*) [/home/chonhyon/project/test/UnrealEngine/Engine/Source/Runtime/Launch/Private/Launch.cpp, line 178]
[Callstack]  16  0x00007f5870c97123  CommonLinuxMain(int, char**, int (*)(wchar_t const*))
[Callstack]  17  0x00007f58706e8f45  /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5) [0x7f58706e8f45]
[Callstack]  18  0x00000000004152d4  Engine/Binaries/Linux/UE4Editor() [0x4152d4]

(mono version 3.2.8 clang 3.6 are used)

I tested it with clean UE 4.14 again, but it doesn’t crash and terminats normally.

[2017.03.02-11.03.51:761][  0]LogRHI: Initializing OpenGL RHI
[2017.03.02-11.03.51:761][  0]LogRHI:   GL_VENDOR: NVIDIA Corporation
[2017.03.02-11.03.51:761][  0]LogRHI:   GL_RENDERER: GeForce GTX 1070/PCIe/SSE2
[2017.03.02-11.03.51:761][  0]LogRHI:   GL_VERSION: 4.3.0 NVIDIA 367.57
[2017.03.02-11.03.51:761][  0]LogRHI:   GL_SHADING_LANGUAGE_VERSION: 4.30 NVIDIA via Cg compiler

I found that UE 4.15 is using GL version 4.3 as default, and also tried -opengl3, but it still crashed in the same point.

Could you run the editor under gdb, exit it, wait it to crash, get the callstack with “bt” and attach it here?

Callstack in GDB

*** Error in `/home/chonhyon/project/test/UnrealEngine/Engine/Binaries/Linux/UE4Editor-Linux-Debug': free(): invalid pointer: 0x00007fff9b0f6f00 ***

Program received signal SIGABRT, Aborted.
0x00007fffe1a56c37 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56      ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  0x00007fffe1a56c37 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1  0x00007fffe1a5a028 in __GI_abort () at abort.c:89
#2  0x00007fffe1a932a4 in __libc_message (do_abort=do_abort@entry=1, fmt=fmt@entry=0x7fffe1ba16b0 "*** Error in `%s': %s: 0x%s ***\n") at ../sysdeps/posix/libc_fatal.c:175
#3  0x00007fffe1a9f55e in malloc_printerr (ptr=<optimized out>, str=0x7fffe1b9d801 "free(): invalid pointer", action=1) at malloc.c:4996
#4  _int_free (av=<optimized out>, p=<optimized out>, have_lock=0) at malloc.c:3840
#5  0x00007fffb330aa05 in FOpenGLRHIState::CleanupResources (this=0x7fffb1a18018) at Runtime/OpenGLDrv/Public/OpenGLState.h:488
#6  0x00007fffb33005ac in FOpenGLDynamicRHI::Cleanup (this=0x7fffb1a18000) at /home/chonhyon/project/test/UnrealEngine/Engine/Source/Runtime/OpenGLDrv/Private/OpenGLDevice.cpp:1514
#7  0x00007fffb3300336 in FOpenGLDynamicRHI::Shutdown (this=0x7fffb1a18000) at /home/chonhyon/project/test/UnrealEngine/Engine/Source/Runtime/OpenGLDrv/Private/OpenGLDevice.cpp:1457
#8  0x00007fffe933274f in RHIExit () at /home/chonhyon/project/test/UnrealEngine/Engine/Source/Runtime/RHI/Private/DynamicRHI.cpp:212
#9  0x0000000000446c6a in RHIExitAndStopRHIThread () at /home/chonhyon/project/test/UnrealEngine/Engine/Source/Runtime/Launch/Private/LaunchEngineLoop.cpp:316
#10 0x0000000000441673 in FEngineLoop::Exit (this=0x69ef98 <GEngineLoop>) at /home/chonhyon/project/test/UnrealEngine/Engine/Source/Runtime/Launch/Private/LaunchEngineLoop.cpp:2658

#11 0x00000000004413db in EngineExit () at /home/chonhyon/project/test/UnrealEngine/Engine/Source/Runtime/Launch/Private/Launch.cpp:73
#12 0x0000000000441a41 in GuardedMain(wchar_t const*)::EngineLoopCleanupGuard::~EngineLoopCleanupGuard() (this=0x7fffffffd968)
at /home/chonhyon/project/test/UnrealEngine/Engine/Source/Runtime/Launch/Private/Launch.cpp:107
#13 0x0000000000441a19 in GuardedMain (CmdLine=0x4738a8 L"") at /home/chonhyon/project/test/UnrealEngine/Engine/Source/Runtime/Launch/Private/Launch.cpp:178
#14 0x00007fffe256adab in CommonLinuxMain (argc=1, argv=0x7fffffffdd98, RealMain=0x4416e0 <GuardedMain(wchar_t const*)>)
at /home/chonhyon/project/test/UnrealEngine/Engine/Source/Runtime/Linux/LinuxCommonStartup/Private/LinuxCommonStartup.cpp:236
#15 0x0000000000448d8c in main (argc=1, argv=0x7fffffffdd98) at /home/chonhyon/project/test/UnrealEngine/Engine/Source/Runtime/Launch/Private/Linux/LaunchLinux.cpp:25
(gdb)

Thank you. I attached the callstack in GDB.

I was able to duplicate this problem with a 4.16 build and tracked it down. The issue is that the FOpenGLHRIState object’s ShaderParameters array is being allocated via the overridden FMemory-based new operator but is being freed via a standard delete operator. It looks like when clang is targeting to C++14, it may emit calls to void operator delete[](void *, size_t), but there is no overridden delete operator with this signature in ModuleBoilerplate.h. The following patch to add the missing signature fixed the problem for me:

diff --git a/Engine/Source/Runtime/Core/Public/Modules/Boilerplate/ModuleBoilerplate.h b/Engine/Source/Runtime/Core/Public/Modules/Boilerplate/ModuleBoilerplate.h
index 979f949..0d67d72 100644
--- a/Engine/Source/Runtime/Core/Public/Modules/Boilerplate/ModuleBoilerplate.h
+++ b/Engine/Source/Runtime/Core/Public/Modules/Boilerplate/ModuleBoilerplate.h
@@ -32,7 +32,8 @@ class FFixedUObjectArray;
        void operator delete  ( void* Ptr )                                                 OPERATOR_DELETE_THROW_SPEC   { FMemory::Free( Ptr ); } \
        void operator delete[]( void* Ptr )                                                 OPERATOR_DELETE_THROW_SPEC   { FMemory::Free( Ptr ); } \
        void operator delete  ( void* Ptr, const std::nothrow_t& )                          OPERATOR_DELETE_NOTHROW_SPEC { FMemory::Free( Ptr ); } \
-       void operator delete[]( void* Ptr, const std::nothrow_t& )                          OPERATOR_DELETE_NOTHROW_SPEC { FMemory::Free( Ptr ); }
+       void operator delete[]( void* Ptr, const std::nothrow_t& )                          OPERATOR_DELETE_NOTHROW_SPEC { FMemory::Free( Ptr ); } \
+       void operator delete[]( void* Ptr, size_t )                                         OPERATOR_DELETE_NOTHROW_SPEC { FMemory::Free( Ptr ); }
 
 class FFixedUObjectArray;