Linux C++ project seg faults when run in game mode

Running a C++ project in game mode in Linux often results in a seg fault (often, but not always - about 50% of the time). Sometimes I need to attempt to run the project (from the terminal) several times before it will start. After I create a default Third Person C++ project, I build it using the following:

$ /bin/sh -c 'mono /opt/UnrealEngine415/Engine/Binaries/DotNET/UnrealBuildTool.exe TestProjectEditor Linux Development -project="/home/syd/Documents/Unreal Projects/TestProject/TestProject.uproject"'

Using clang version '3.9.0' (string), 3 (major), 9 (minor), 0 (patch)
Performing full C++ include scan (no include cache file)
Performing 1 actions (8 in parallel)
[1/1] FixDeps UE4Editor
Fixing libUE4Editor-UMG.so
Fixing libUE4Editor-SourceControl.so
Fixing libUE4Editor-CinematicCamera.so
Fixing libUE4Editor-Sequencer.so
Fixing libUE4Editor-MaterialUtilities.so
Fixing libUE4Editor-AITestSuite.so
Fixing libUE4Editor-GameplayTags.so
Fixing libUE4Editor-AIModule.so
Fixing libUE4Editor-MovieSceneTools.so
Fixing libUE4Editor-KismetCompiler.so
Fixing libUE4Editor-BlueprintGraph.so
Fixing libUE4Editor-UMGEditor.so
Fixing libUE4Editor-Kismet.so
Fixing libUE4Editor-LocalizationService.so
Fixing libUE4Editor-TranslationEditor.so
Fixing libUE4Editor-MainFrame.so
Fixing libUE4Editor-AudioEditor.so
Fixing libUE4Editor-GraphEditor.so
Fixing libUE4Editor-UnrealEd.so
/opt/UnrealEngine415/Engine/Source/ThirdParty/FBX/2016.1.1/lib/gcc4/x86_64-unknown-linux-gnu/release//libfbxsdk.a(fbxutils.o): In function `fbxsdk::FbxPathUtils::GenerateFileName(char const*, char const*)':
(.text+0x4b8): warning: the use of `tempnam' is dangerous, better use `mkstemp'
Fixing libUE4Editor-PropertyEditor.so
Fixing libUE4Editor-MaterialShaderQualitySettings.so
Fixing libUE4Editor-Landscape.so
Fixing libUE4Editor-CollisionAnalyzer.so
Fixing libUE4Editor-LogVisualizer.so
Fixing libUE4Editor-ReliabilityHandlerComponent.so
Total build time: 132.50 seconds (Local executor: 86.09 seconds)

I then attempt to run the project in game mode using the following:

$ /opt/UnrealEngine415/Engine/Binaries/Linux/UE4Editor "/home/syd/Documents/Unreal Projects/TestProject/TestProject.uproject" -game

Using binned.
Increasing per-process limit of core file size to infinity.
LogInit:Display: Running engine for game: TestProject
LogPlatformFile: Not using cached  wrapper
LogInit:Display: RandInit(-442443806) SRandInit(-442443806).
LogTaskGraph: Started task graph with 5 named threads and 8 total threads with 1 sets of task threads.
LogStats: Stats thread started at 0.030992
LogInit: Using libcurl 7.48.0-DEV
LogInit:  - built for x86_64-unknown-linux-gnu
LogInit:  - supports SSL with OpenSSL/1.0.2h
LogInit:  - supports HTTP deflate (compression) using libz 1.2.8
LogInit:  - other features:
LogInit:      CURL_VERSION_SSL
LogInit:      CURL_VERSION_LIBZ
LogInit:      CURL_VERSION_IPV6
LogInit:      CURL_VERSION_ASYNCHDNS
LogInit:      CURL_VERSION_LARGEFILE
LogInit:      CURL_VERSION_TLSAUTH_SRP
LogInit:  Libcurl: checking if '/etc/pki/tls/certs/ca-bundle.crt' exists
LogInit:  Libcurl: checking if '/etc/ssl/certs/ca-certificates.crt' exists
LogInit:  CurlRequestOptions (configurable via config and command line):
LogInit:  - bVerifyPeer = true  - Libcurl will verify peer certificate
LogInit:  - bUseHttpProxy = false  - Libcurl will NOT use HTTP proxy
LogInit:  - bDontReuseConnections = false  - Libcurl will reuse connections
LogInit:  - CertBundlePath = /etc/ssl/certs/ca-certificates.crt  - Libcurl will set CURLOPT_CAINFO to it
LogInit: Build: ++UE4+Release-4.15-CL-0
LogInit: Engine Version: 4.15.0-0+++UE4+Release-4.15
LogInit: Compatible Engine Version: 4.15.0-0+++UE4+Release-4.15
LogInit: Net CL: 0
LogDevObjectVersion: Number of dev versions registered: 14
LogDevObjectVersion:   Dev-Blueprints (B0D832E4-1F89-4F0D-ACCF-7EB736FD4AA2): 8
LogDevObjectVersion:   Dev-Build (E1C64328-A22C-4D53-A36C-8E866417BD8C): 0
LogDevObjectVersion:   Dev-Core (375EC13C-06E4-48FB-B500-84F0262A717E): 2
LogDevObjectVersion:   Dev-Editor (E4B068ED-F494-42E9-A231-DA0B2E46BB41): 14
LogDevObjectVersion:   Dev-Framework (CFFC743F-43B0-4480-9391-14DF171D2073): 22
LogDevObjectVersion:   Dev-Mobile (B02B49B5-BB20-44E9-A304-32B752E40360): 0
LogDevObjectVersion:   Dev-Networking (A4E4105C-59A1-49B5-A7C5-40C4547EDFEE): 0
LogDevObjectVersion:   Dev-Online (39C831C9-5AE6-47DC-9A44-9C173E1C8E7C): 0
LogDevObjectVersion:   Dev-Physics (78F01B33-EBEA-4F98-B9B4-84EACCB95AA2): 0
LogDevObjectVersion:   Dev-Platform (6631380F-2D4D-43E0-8009-CF276956A95A): 0
LogDevObjectVersion:   Dev-Rendering (12F88B9F-8875-4AFC-A67C-D90C383ABD29): 12
LogDevObjectVersion:   Dev-Sequencer (7B5AE74C-D270-4C10-A958-57980B212A5A): 3
LogDevObjectVersion:   Dev-VR (D7296918-1DD6-4BDD-9DE2-64A83CC13884): 0
LogDevObjectVersion:   Dev-LoadTimes (C2A15278-BFE7-4AFE-6C17-90FF531DF755): 1
LogInit: Compiled (64-bit): Feb 21 2017 00:04:46
LogInit: Compiled with Clang: 3.9.0 (tags/RELEASE_390/final)
LogInit: Build Configuration: Development
LogInit: Branch Name: ++UE4+Release-4.15
LogInit: Command line:  -game
LogInit: Base directory: /opt/UnrealEngine415/Engine/Binaries/Linux/
LogInit: Installed Engine Build: 0
LogInit: Presizing for max 8388607 objects, including 0 objects not considered by GC, pre-allocating 0 bytes for permanent pool.
LogInit: Object subsystem initialized
[2017.02.21-23.15.53:099][  0]LogInit: Initializing SDL.
[2017.02.21-23.15.53:244][  0]LogInit: Initialized SDL 2.0.4 revision: 10374 (hg-10374:dccf51aee79b with EpicExtensions) (compiled against 2.0.4)
[2017.02.21-23.15.53:244][  0]LogInit: Display metrics:
[2017.02.21-23.15.53:244][  0]LogInit:   PrimaryDisplayWidth: 1920
[2017.02.21-23.15.53:244][  0]LogInit:   PrimaryDisplayHeight: 1080
[2017.02.21-23.15.53:244][  0]LogInit:   PrimaryDisplayWorkAreaRect:
[2017.02.21-23.15.53:244][  0]LogInit:     Left=43, Top=24, Right=1920, Bottom=1080
[2017.02.21-23.15.53:244][  0]LogInit:   VirtualDisplayRect:
[2017.02.21-23.15.53:244][  0]LogInit:     Left=43, Top=24, Right=1920, Bottom=1080
[2017.02.21-23.15.53:244][  0]LogInit:   TitleSafePaddingSize: X=0.000 Y=0.000
[2017.02.21-23.15.53:244][  0]LogInit:   ActionSafePaddingSize: X=0.000 Y=0.000
[2017.02.21-23.15.53:244][  0]LogInit:   Number of monitors: 1
[2017.02.21-23.15.53:244][  0]LogInit:     Monitor 0
[2017.02.21-23.15.53:244][  0]LogInit:       Name: 0
[2017.02.21-23.15.53:244][  0]LogInit:       ID: display0
[2017.02.21-23.15.53:244][  0]LogInit:       NativeWidth: 1920
[2017.02.21-23.15.53:244][  0]LogInit:       NativeHeight: 1080
[2017.02.21-23.15.53:244][  0]LogInit:       bIsPrimary: true
[2017.02.21-23.15.53:245][  0]LogLinux: Selected Device Profile: [Linux]
[2017.02.21-23.15.53:245][  0]LogInit: Applying CVar settings loaded from the selected device profile: [Linux]
[2017.02.21-23.15.53:253][  0]LogInit: Linux hardware info:
[2017.02.21-23.15.53:253][  0]LogInit:  - we are the first instance of this executable
[2017.02.21-23.15.53:253][  0]LogInit:  - this process' id (pid) is 16603, parent process' id (ppid) is 13876
[2017.02.21-23.15.53:253][  0]LogInit:  - we are not running under debugger
[2017.02.21-23.15.53:253][  0]LogInit:  - machine network name is 'd2'
[2017.02.21-23.15.53:253][  0]LogInit:  - user name is 'syd' (syd)
[2017.02.21-23.15.53:253][  0]LogInit:  - we're logged in locally
[2017.02.21-23.15.53:253][  0]LogInit:  - we're running with rendering
[2017.02.21-23.15.53:253][  0]LogInit:  - CPU: GenuineIntel 'Intel(R) Core(TM) i7-6820HK CPU @ 2.70GHz' (signature: 0x506E3)
[2017.02.21-23.15.53:253][  0]LogInit:  - Number of physical cores available for the process: 4
[2017.02.21-23.15.53:253][  0]LogInit:  - Number of logical cores available for the process: 8
[2017.02.21-23.15.53:253][  0]LogInit:  - Cache line size: 64
[2017.02.21-23.15.53:253][  0]LogInit:  - Memory allocator used: binned
[2017.02.21-23.15.53:253][  0]LogLinux: Benchmarking clocks:
[2017.02.21-23.15.53:253][  0]LogLinux:  - CLOCK_REALTIME (id=0) can sustain 50734037 (50734K, 51M) calls per second without zero deltas.
[2017.02.21-23.15.53:253][  0]LogLinux:  - CLOCK_MONOTONIC (id=1) can sustain 52945490 (52945K, 53M) calls per second without zero deltas.
[2017.02.21-23.15.53:253][  0]LogLinux:  - CLOCK_MONOTONIC_RAW (id=4) can sustain 11564776 (11565K, 12M) calls per second without zero deltas.
[2017.02.21-23.15.53:253][  0]LogLinux:  - CLOCK_MONOTONIC_COARSE (id=6) can sustain 202128987 (202129K, 202M) calls per second with 99.999872% zero deltas.
[2017.02.21-23.15.53:253][  0]LogLinux: Selected clock_id 1 (CLOCK_MONOTONIC) since it is the fastest support clock without zero deltas.
[2017.02.21-23.15.53:254][  0]LogInit: Linux-specific commandline switches:
[2017.02.21-23.15.53:254][  0]LogInit:  -nodwarf (currently OFF): suppress parsing of DWARF debug info (callstacks will be generated faster, but won't have line numbers)
[2017.02.21-23.15.53:254][  0]LogInit:  -ansimalloc - use malloc()/free() from libc (useful for tools like valgrind and electric fence)
[2017.02.21-23.15.53:254][  0]LogInit:  -jemalloc - use jemalloc for all memory allocation
[2017.02.21-23.15.53:254][  0]LogInit:  -binnedmalloc - use binned malloc  for all memory allocation
[2017.02.21-23.15.53:254][  0]LogInit:  -httpproxy=ADDRESS:PORT - redirects HTTP requests to a proxy (only supported if compiled with libcurl)
[2017.02.21-23.15.53:254][  0]LogInit:  -reuseconn - allow libcurl to reuse HTTP connections (only matters if compiled with libcurl)
[2017.02.21-23.15.53:254][  0]LogInit:  -virtmemkb=NUMBER - sets process virtual memory (address space) limit (overrides VirtualMemoryLimitInKB value from .ini)
[2017.02.21-23.15.53:254][  0]LogInit:  - Physical RAM available (not considering process quota): 32 GB (32127 MB, 32898260 KB, 33687818240 bytes)
[2017.02.21-23.15.53:262][  0]LogTextLocalizationManager: No specific translations for ('en-GB') exist, so ('en') translations will be used.
Signal 11 caught.
Malloc Size=131076 LargeMemoryPoolOffset=131092 
CommonLinuxCrashHandler: Signal=11
Malloc Size=65535 LargeMemoryPoolOffset=196655 
Using binned.
LogPlatformFile: Not using cached  wrapper
LogInit:Display: RandInit(-1883036250) SRandInit(-1883036250).
LogTaskGraph: Started task graph with 4 named threads and 7 total threads with 1 sets of task threads.
LogInit: Build: ++UE4+Release-4.15-CL-0
LogInit: Engine Version: 4.15.0-0+++UE4+Release-4.15
LogInit: Compatible Engine Version: 4.15.0-0+++UE4+Release-4.15
LogInit: Net CL: 0
LogInit: Compiled (64-bit): Feb 20 2017 22:13:34
LogInit: Compiled with Clang: 3.9.0 (tags/RELEASE_390/final)
LogInit: Build Configuration: Shipping
LogInit: Branch Name: ++UE4+Release-4.15
LogInit: Command line:  -Abslog=/home/syd/Documents/Unreal Projects/TestProject/Saved/Logs/TestProject-CRC.log /home/syd/Documents/Unreal Projects/TestProject/Saved/Crashes/crashinfo-TestProject-pid-16603-00037DF835021715000F02CBE5C1EE09/
LogInit: Base directory: /opt/UnrealEngine415/Engine/Binaries/Linux/
LogInit: Installed Engine Build: 1
LogInit: Presizing for max 100000 objects, including 0 objects not considered by GC, pre-allocating 0 bytes for permanent pool.
LogInit: Object subsystem initialized
[2017.02.21-23.15.53:806][  0]LogInit: Linux hardware info:
[2017.02.21-23.15.53:806][  0]LogInit:  - we are the first instance of this executable
[2017.02.21-23.15.53:806][  0]LogInit:  - this process' id (pid) is 16627, parent process' id (ppid) is 16603
[2017.02.21-23.15.53:806][  0]LogInit:  - we are not running under debugger
[2017.02.21-23.15.53:806][  0]LogInit:  - machine network name is 'd2'
[2017.02.21-23.15.53:806][  0]LogInit:  - user name is 'syd' (syd)
[2017.02.21-23.15.53:806][  0]LogInit:  - we're logged in locally
[2017.02.21-23.15.53:806][  0]LogInit:  - we're running with rendering
[2017.02.21-23.15.53:806][  0]LogInit:  - CPU: GenuineIntel 'Intel(R) Core(TM) i7-6820HK CPU @ 2.70GHz' (signature: 0x506E3)
[2017.02.21-23.15.53:806][  0]LogInit:  - Number of physical cores available for the process: 4
[2017.02.21-23.15.53:806][  0]LogInit:  - Number of logical cores available for the process: 8
[2017.02.21-23.15.53:806][  0]LogInit:  - Cache line size: 64
[2017.02.21-23.15.53:806][  0]LogInit:  - Memory allocator used: binned
[2017.02.21-23.15.53:806][  0]LogLinux: Skipped benchmarking clocks because the engine is running in a standalone program mode - CLOCK_REALTIME will be used.
[2017.02.21-23.15.53:806][  0]LogInit: Linux-specific commandline switches:
[2017.02.21-23.15.53:806][  0]LogInit:  -nodwarf (currently OFF): suppress parsing of DWARF debug info (callstacks will be generated faster, but won't have line numbers)
[2017.02.21-23.15.53:806][  0]LogInit:  -ansimalloc - use malloc()/free() from libc (useful for tools like valgrind and electric fence)
[2017.02.21-23.15.53:806][  0]LogInit:  -jemalloc - use jemalloc for all memory allocation
[2017.02.21-23.15.53:806][  0]LogInit:  -binnedmalloc - use binned malloc  for all memory allocation
[2017.02.21-23.15.53:806][  0]LogInit:  -httpproxy=ADDRESS:PORT - redirects HTTP requests to a proxy (only supported if compiled with libcurl)
[2017.02.21-23.15.53:806][  0]LogInit:  -reuseconn - allow libcurl to reuse HTTP connections (only matters if compiled with libcurl)
[2017.02.21-23.15.53:806][  0]LogInit:  -virtmemkb=NUMBER - sets process virtual memory (address space) limit (overrides VirtualMemoryLimitInKB value from .ini)
[2017.02.21-23.15.53:806][  0]LogInit:  - Physical RAM available (not considering process quota): 32 GB (32127 MB, 32898260 KB, 33687818240 bytes)
[2017.02.21-23.15.53:806][  0]LogUObjectArray: 146 objects as part of root set at end of initial load.
[2017.02.21-23.15.53:806][  0]LogUObjectAllocator: 24096 out of 0 bytes used by permanent object pool.
[2017.02.21-23.15.53:806][  0]LogUObjectArray: CloseDisregardForGC: 0/0 objects in disregard for GC pool
[2017.02.21-23.15.53:806][  0]LogTextLocalizationManager: No translations for ('') exist, falling back to 'en' for localization and internationalization data.
[2017.02.21-23.15.53:808][  0]CrashReportClientLog: CrashReportClientVersion=1.0
[2017.02.21-23.15.53:808][  0]CrashReportClientLog: CrashReportReceiver disabled
[2017.02.21-23.15.53:808][  0]CrashReportClientLog: DataRouterUrl: https://datarouter.ol.epicgames.com/datarouter/api/v1/public/data
[2017.02.21-23.15.53:808][  0]LogExit: Preparing to exit.
[2017.02.21-23.15.53:808][  0]LogObj: Freed 0b from 0 cluster array pools.
[2017.02.21-23.15.53:808][  0]LogExit: Object subsystem successfully closed.
[2017.02.21-23.15.53:809][  0]LogModuleManager: Shutting down and abandoning module CoreUObject (2)
[2017.02.21-23.15.53:809][  0]LogExit: Exiting.
Signal 11 caught.
Engine crash handling finished; re-raising signal 11 for the default handler. Good bye.
Segmentation fault (core dumped)

I tried using UE4 4.14 and Clang 3.8, the same problem occurs.

I am also able to reproduce this problem within the UE4Editor:

  • Start UE4Editor.
  • Open the C++ project.
  • In the Play dropdown, select Standalone Game.
  • Press Play, then quit ← repeat, eventually crash occurs (standalone game fails to start).
  • Error reported: UE4Editor crashed with SIGSEGV in X11_ShowCursor()

After further investigation (looking at X11_ShowCursor() in Engine/Source/ThirdParty/SDL2/SDL-gui-backend/src/video/x11/SDL_x11mouse.c) I am now able to reliably reproduce this issue. It only occurs if the mouse pointer is positioned in same area the UE4 splash screen occupies. This is true whether the project is started in game mode using the terminal, or CodeLite, or the UE4 project browser.

You are probably running into a threading issue in the splash screen code. Could you please try to get the full callstack? It should be in one of the files under your Project/Saved/Crashes - e.g. at the end of the log file there.

TestProject.log

Here’s my TestProject.log file. Just to be clear, no custom code was added. This is simply creating a new Third Person C++ project and then building/running it in game mode (with the mouse cursor positioned in the area the UE4 splash screen appears).

Sorry, the previous log file was generated in Development Mode. Here’s one that was generated in Debug mode.

link text

Here’s a (really bad) video demonstrating the issue:

https://youtu.be/hD3sHASN7mg

On the first attempt to execute the project (third person C++, no custom code), I move the mouse cursor to the center of the screen - where the splash screen normally appears. Seg fault occurs.

On the second attempt to execute the project, I move the mouse pointer to the top left-hand part of the screen, and the project starts in game mode as expected.

Hey-

I tried to reproduce the crash in a code project by launching standalone game as you suggested but did not receive a crash after several attempts. What desktop environment are you using? Also, it appears you have other effects enabled (such as the windows ‘closing’ in puffs of flames). Does the crash still occur if you disable these effects? If possible, can you let me know if the crash occurs under a clean desktop environment or explain how you setup your desktop environment so I can test the same settings locally?