How to Fix a Unity3D Linux Build Crash on Start

I recently ran into a frustrating problem while trying to build a simple Unity3D project for Linux using Ubuntu. My project was nothing fancy just an empty scene with an attached script yet when I launched the build, it crashed immediately. No warnings in Unity, no errors during the build just a crash on startup.

If you’re here, maybe you’ve hit the same wall. Here’s what happened, what caused it.

The Setup A Minimal Project

To keep things as simple as possible, I created a brand-new Unity project. I added a GameObject and attached the following minimal script to it:

using UnityEngine;

public class Main : MonoBehaviour
{
void Start()
{
Debug.Log("Application Started");
}

void Update()
{
// Nothing here
}
}

Then I built it using:

  • Platform: Linux
  • Architecture: x86 (32-bit)

After building, I tried to run the executable (Empty_Linux.x86) and… crash.

The Crash Error

Here’s what I got in the terminal:

terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_S_construct null not valid

And in the Player.log file:

XError: BadMatch (invalid parameter attributes)
Got a SIGABRT while executing native code.

Yikes. Nothing in Unity warned me this might happen.

Breaking Down the Error

The line:

what():  basic_string::_S_construct null not valid

tells us that somewhere in Unity’s native code or Mono runtime, it tried to construct a string from a null pointer, which is illegal in C++. That’s a fatal error that crashes the application.

This most likely happened because Unity tried to fetch some configuration (like display mode, controller config, etc.) and received a null value instead.

Root Cause Analysis

After hours of digging and reading forums, I found a few possible root causes:

Missing or incompatible OpenGL / GLX setup

XError: BadMatch (invalid parameter attributes)

Unity might be asking for a graphics configuration that your system can’t provide especially common on virtual machines, systems with NVIDIA proprietary drivers, or when using Wayland instead of X11.

Wrong Build Architecture

Most modern Linux distributions don’t have all the 32-bit dependencies installed by default. If you build for x86 (32-bit) and run it on a 64-bit system without those libraries, you’ll likely crash.

Corrupted or missing Mono runtime files

Unity’s embedded Mono runtime might not be able to initialize if certain files or paths are broken or missing.

Faulty joystick or game controller config

Using libudev for joystick management
Importing game controller configs

If Unity tries to load game controller mappings and encounters a null, the app can crash. This is surprisingly common.

Explain Fix It

Build for x86_64 (64-bit) Instead of x86

This was the game changer for me.

Go to:

  • File > Build Settings > Player Settings
  • Under Other Settings, change Architecture to x86_64

Then rebuild and run it.

Install the Required Libraries

For 64-bit builds, I ran:

sudo apt update
sudo apt install libgl1-mesa-dev libxcursor1 libxrandr2 libxinerama1 libxi6 libglib2.0-0 libudev1 libstdc++6

If you’re still using 32-bit (not recommended), install:

sudo dpkg --add-architecture i386
sudo apt update
sudo apt install libc6:i386 libstdc++6:i386 libx11-6:i386 \
libxcursor1:i386 libxrandr2:i386 libxinerama1:i386 libxi6:i386 libudev1:i386

Disable Controller Input

Go to:

  • Edit > Project Settings > Input Manager
  • Remove or comment out the joystick axes

Or add this line in your script to reset input:

Input.ResetInputAxes();

Run the Build with Logs Enabled

Run your executable with this command to capture logs:

./Empty_Linux.x86_64 -logFile ./log.txt

Then open log.txt to check what’s going wrong.

Extra Practice Functionality

Once the crash was fixed, I added some basic features to confirm the build worked end-to-end.Toggle Fullscreen with a Key

void Update()
{
if (Input.GetKeyDown(KeyCode.F))
{
Screen.fullScreen = !Screen.fullScreen;
Debug.Log("Toggled Fullscreen");
}
}

Show Screen Resolution on UI

void OnGUI()
{
GUI.Label(new Rect(10, 10, 300, 20), "Resolution: " + Screen.currentResolution);
}

Catch Basic Errors in Runtime

void Start()
{
Application.logMessageReceived += HandleLog;
}

void HandleLog(string logString, string stackTrace, LogType type)
{
if (type == LogType.Exception)
Debug.LogError("Caught exception: " + logString);
}

Final Thought

Fixing Unity3D Linux crashes wasn’t as straightforward as I hoped, especially for such a small project. It turned out that the issue wasn’t in my code, but in the architecture mismatch and Linux environment dependencies.

Related blog posts