Cooking fails with signal 11 on Linux

I tried cooking my project on linux using the editor, unreal front end and directly running UE4Editor -run=Cook ...
and all of them failed to cook the project. The actual cooking succeeds but the engine crashes afterwards making the tools think that the cooking failed.

    MainFrMainFrameActions: Cooking (Linux): UE4Editor: [2016.05.25-14.41.54:939][  0]LogInit:Display: 
MainFrameActions: Cooking (Linux): UE4Editor: 1101[2016.05.25-14.41.54:939][  0]LogInit:Display: Success - 0 error(s), 58 warning(s)
MainFrameActions: Cooking (Linux): UE4Editor: [2016.05.25-14.41.54:939][  0]LogInit:Display: 
MainFrameActions: Cooking (Linux): UE4Editor: Execution of commandlet took:  10.44 seconds
MainFrameActions: Cooking (Linux): UE4Editor: Signal 11 caught.
MainFrameActions: Cooking (Linux): UE4Editor: EngineCrashHandler: Signal=11
MainFrameActions: Cooking (Linux): UE4Editor: === Critical error: ===
MainFrameActions: Cooking (Linux): UE4Editor: Unhandled Exception: SIGSEGV: invalid attempt to access memory at address 0x00804930
MainFrameActions: Cooking (Linux): UE4Editor: Fatal error!
MainFrameActions: Cooking (Linux): UE4Editor: 
MainFrameActions: Cooking (Linux): UE4Editor: [Callstack]  03  0x00007f94564f7510  CommonLinuxCrashHandler(FGenericCrashContext const&)
MainFrameActions: Cooking (Linux): UE4Editor: [Callstack]  04  0x00007f9461920708  PlatformCrashHandler(int, siginfo_t*, void*)
MainFrameActions: Cooking (Linux): UE4Editor: [Callstack]  05  0x00007f94624bc9f0  /lib64/libpthread.so.0(+0x109f0) [0x7f94624bc9f0]
MainFrameActions: Cooking (Linux): UE4Editor: [Callstack]  06  0x00007f9461bd4655  /home/hhyyrylainen/Projects/UnrealEngine/Engine/Binaries/Linux/libUE4Editor-Core.so(je_malloc_usable_size+0x55) [0x7f9461bd4655]
MainFrameActions: Cooking (Linux): UE4Editor: [Callstack]  07  0x00007f94618691a1  FMallocJemalloc::Free(void*)
MainFrameActions: Cooking (Linux): UE4Editor: [Callstack]  08  0x00007f946187031a  FMemory::Free(void*)
MainFrameActions: Cooking (Linux): UE4Editor: [Callstack]  09  0x00007f93e24e0c16  /home/hhyyrylainen/Projects/fabricators/Binaries/Linux/libUE4Editor-Fabricators.so(+0xa7c16) [0x7f93e24e0c16]
MainFrameActions: Cooking (Linux): UE4Editor: [Callstack]  10  0x00007f93e25af219  /home/hhyyrylainen/Projects/fabricators/Binaries/Linux/libUE4Editor-Fabricators.so(+0x176219) [0x7f93e25af219]
MainFrameActions: Cooking (Linux): UE4Editor: [Callstack]  11  0x00007f945549d5e8  /lib64/libc.so.6(+0x395e8) [0x7f945549d5e8]
MainFrameActions: Cooking (Linux): UE4Editor: [Callstack]  12  0x00007f945549d635  /lib64/libc.so.6(+0x39635) [0x7f945549d635]
MainFrameActions: Cooking (Linux): UE4Editor: [Callstack]  13  0x00007f9455484587  /lib64/libc.so.6(__libc_start_main+0xf7) [0x7f9455484587]
MainFrameActions: Cooking (Linux): UE4Editor: [Callstack]  14  0x0000000000412f99  /home/hhyyrylainen/Projects/UnrealEngine/Engine/Binaries/Linux/UE4Editor(_start+0x29) [0x412f99]
MainFrameActions: Cooking (Linux): UE4Editor: Starting ../../../Engine/Binaries/Linux/CrashReportClientameActions: Cooking (Linux): UE4Editor: [2016.05.25-14.41.54:939][  0]LogInit:Display: 
MainFrameActions: Cooking (Linux): UE4Editor: 1101[2016.05.25-14.41.54:939][  0]LogInit:Display: Success - 0 error(s), 58 warning(s)
MainFrameActions: Cooking (Linux): UE4Editor: [2016.05.25-14.41.54:939][  0]LogInit:Display: 
MainFrameActions: Cooking (Linux): UE4Editor: Execution of commandlet took:  10.44 seconds
MainFrameActions: Cooking (Linux): UE4Editor: Signal 11 caught.
MainFrameActions: Cooking (Linux): UE4Editor: EngineCrashHandler: Signal=11
MainFrameActions: Cooking (Linux): UE4Editor: === Critical error: ===
MainFrameActions: Cooking (Linux): UE4Editor: Unhandled Exception: SIGSEGV: invalid attempt to access memory at address 0x00804930
MainFrameActions: Cooking (Linux): UE4Editor: Fatal error!
MainFrameActions: Cooking (Linux): UE4Editor: 
MainFrameActions: Cooking (Linux): UE4Editor: [Callstack]  03  0x00007f94564f7510  CommonLinuxCrashHandler(FGenericCrashContext const&)
MainFrameActions: Cooking (Linux): UE4Editor: [Callstack]  04  0x00007f9461920708  PlatformCrashHandler(int, siginfo_t*, void*)
MainFrameActions: Cooking (Linux): UE4Editor: [Callstack]  05  0x00007f94624bc9f0  /lib64/libpthread.so.0(+0x109f0) [0x7f94624bc9f0]
MainFrameActions: Cooking (Linux): UE4Editor: [Callstack]  06  0x00007f9461bd4655  /home/hhyyrylainen/Projects/UnrealEngine/Engine/Binaries/Linux/libUE4Editor-Core.so(je_malloc_usable_size+0x55) [0x7f9461bd4655]
MainFrameActions: Cooking (Linux): UE4Editor: [Callstack]  07  0x00007f94618691a1  FMallocJemalloc::Free(void*)
MainFrameActions: Cooking (Linux): UE4Editor: [Callstack]  08  0x00007f946187031a  FMemory::Free(void*)
MainFrameActions: Cooking (Linux): UE4Editor: [Callstack]  09  0x00007f93e24e0c16  /home/hhyyrylainen/Projects/fabricators/Binaries/Linux/libUE4Editor-Fabricators.so(+0xa7c16) [0x7f93e24e0c16]
MainFrameActions: Cooking (Linux): UE4Editor: [Callstack]  10  0x00007f93e25af219  /home/hhyyrylainen/Projects/fabricators/Binaries/Linux/libUE4Editor-Fabricators.so(+0x176219) [0x7f93e25af219]
MainFrameActions: Cooking (Linux): UE4Editor: [Callstack]  11  0x00007f945549d5e8  /lib64/libc.so.6(+0x395e8) [0x7f945549d5e8]
MainFrameActions: Cooking (Linux): UE4Editor: [Callstack]  12  0x00007f945549d635  /lib64/libc.so.6(+0x39635) [0x7f945549d635]
MainFrameActions: Cooking (Linux): UE4Editor: [Callstack]  13  0x00007f9455484587  /lib64/libc.so.6(__libc_start_main+0xf7) [0x7f9455484587]
MainFrameActions: Cooking (Linux): UE4Editor: [Callstack]  14  0x0000000000412f99  /home/hhyyrylainen  /Projects/UnrealEngine/Engine/Binaries/Linux/UE4Editor(_start+0x29) [0x412f99]
MainFrameActions: Cooking (Linux): UE4Editor: Starting ../../../Engine/Binaries/Linux/CrashReportClient

I’m using the release branch. Fedora 23, clang 3.8.

I can run my project just fine, so I don’t think those are the issue.

Using gdb I get the following callstack for the crash:

0  in pthread_mutex_lock of /lib64/libpthread.so.0
1  in je_malloc_mutex_lock of include/jemalloc/internal/mutex.h:77
2  in je_tcache_bin_flush_small of src/tcache.c:105
3  in je_tcache_dalloc_small of include/jemalloc/internal/tcache.h:402
4  in je_arena_dalloc of include/jemalloc/internal/arena.h:1044
5  in je_idalloct of include/jemalloc/internal/jemalloc_internal.h:898
6  in je_iqalloct of include/jemalloc/internal/jemalloc_internal.h:917
7  in je_iqalloc of include/jemalloc/internal/jemalloc_internal.h:924
8  in ifree of src/jemalloc.c:1233
9  in je_free of src/jemalloc.c:1308
10 in FMemory::Free of /home/hhyyrylainen/Projects/UnrealEngine/Engine/Source/Runtime/Core/Private/HAL/UnrealMemory.cpp:114
11 in FHeapAllocator::ForAnyElementType::~ForAnyElementType of Runtime/Core/Public/Containers/ContainerAllocationPolicies.h:342
12 in TArray<wchar_t, FDefaultAllocator>::~TArray of Runtime/Core/Public/Containers/Array.h:691
13 in FString::~FString of Runtime/Core/Public/Containers/UnrealString.h:47
14 in TGeneratedTextData<FTextHistory_Base>::~TGeneratedTextData of Runtime/Core/Private/Internationalization/TextData.h:125
15 in TGeneratedTextData<FTextHistory_Base>::~TGeneratedTextData of Runtime/Core/Private/Internationalization/TextData.h:124
16 in SharedPointerInternals::FReferenceControllerOps<(ESPMode)1>::ReleaseSharedReference of /home/hhyyrylainen/Projects/UnrealEngine/Engine/Source/Runtime/Core/Public/Templates/SharedPointerInternals.h:226
17 in SharedPointerInternals::FSharedReferencer<(ESPMode)1>::~FSharedReferencer of /home/hhyyrylainen/Projects/UnrealEngine/Engine/Source/Runtime/Core/Public/Templates/SharedPointerInternals.h:389
18 in TSharedRef<ITextData, (ESPMode)1>::~TSharedRef of Runtime/Core/Public/Templates/SharedPointer.h:133
19 in FText::~FText of Runtime/Core/Public/Internationalization/Text.h:138
20 in __cxa_finalize of /lib64/libc.so.6
21 in __do_global_dtors_aux of /home/hhyyrylainen/Projects/UnrealEngine/Engine/Binaries/Linux/libUE4Editor-EditorStyle.so
22 in ??
23 in _dl_fini of /lib64/ld-linux-x86-64.so.2

Which looks like it might be caused by a static FText object that is being deleted after jemalloc cannot be used anymore.

Here’s the core file from the gdb session

There doesn’t seem to be any easy workaround, so I guess I can’t run servers on linux.

Edit: Using -ansimalloc gets rid of the error. Which again hints that this is caused by using jemalloc after it has been shut down.
I can now cook my project from the command line, but not from the editor, with this command:
./UE4Editor -run=Cook -ansimalloc -unattended -TargetPlatform=LinuxNoEditor "/path/to/project/Project.uproject"

Well this seems to be fixed in 4.12.2

I hope it has indeed been fixed, and not just different order of static object destruction. I did a quick search in our JIRA and I am not finding which ticket would it be related to…