Linux Terraria Server v1.4.0.3 System.SystemException: Thread creation failed

CardboardMF

Terrarian
I'm in the midst of setting up a v1403 Terraria server on Ubuntu 18.04 (console only).
Once world generation is complete and all of the prompts for ports and such are asked and answered, I get the following exception:

Code:
Terraria Server v1.4.0.3

Listening on port 7777
Type 'help' for a list of commands.

: ================
5/21/2020 8:50:14 AM: Unhandled Exception
Thread: 7 [Server Loop Thread]
Culture: en-US
Exception: System.SystemException: Thread creation failed.
  at System.Threading.Thread.StartInternal (System.Security.Principal.IPrincipal principal, System.Threading.StackCrawlMark& stackMark) [0x00035] in <1170fb08300b4d0db71c1d1db8555768>:0
  at System.Threading.Thread.Start (System.Threading.StackCrawlMark& stackMark) [0x0002d] in <1170fb08300b4d0db71c1d1db8555768>:0
  at System.Threading.Thread.Start () [0x00002] in <1170fb08300b4d0db71c1d1db8555768>:0
  at Terraria.Netplay.StartBroadCasting () [0x00022] in <1d95b9da8f7e4a9b96cec0bf3d2db575>:0
  at Terraria.Netplay.ServerLoop () [0x00002] in <1d95b9da8f7e4a9b96cec0bf3d2db575>:0
  at System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) [0x00017] in <1170fb08300b4d0db71c1d1db8555768>:0
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x0008d] in <1170fb08300b4d0db71c1d1db8555768>:0
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <1170fb08300b4d0db71c1d1db8555768>:0
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) [0x00031] in <1170fb08300b4d0db71c1d1db8555768>:0
  at System.Threading.ThreadHelper.ThreadStart () [0x0000b] in <1170fb08300b4d0db71c1d1db8555768>:0
================
[ERROR] FATAL UNHANDLED EXCEPTION: System.SystemException: Thread creation failed.
  at System.Threading.Thread.StartInternal (System.Security.Principal.IPrincipal principal, System.Threading.StackCrawlMark& stackMark) [0x00035] in <1170fb08300b4d0db71c1d1db8555768>:0
  at System.Threading.Thread.Start (System.Threading.StackCrawlMark& stackMark) [0x0002d] in <1170fb08300b4d0db71c1d1db8555768>:0
  at System.Threading.Thread.Start () [0x00002] in <1170fb08300b4d0db71c1d1db8555768>:0
  at Terraria.Netplay.StartBroadCasting () [0x00022] in <1d95b9da8f7e4a9b96cec0bf3d2db575>:0
  at Terraria.Netplay.ServerLoop () [0x00002] in <1d95b9da8f7e4a9b96cec0bf3d2db575>:0
  at System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) [0x00017] in <1170fb08300b4d0db71c1d1db8555768>:0
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x0008d] in <1170fb08300b4d0db71c1d1db8555768>:0
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <1170fb08300b4d0db71c1d1db8555768>:0
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) [0x00031] in <1170fb08300b4d0db71c1d1db8555768>:0
  at System.Threading.ThreadHelper.ThreadStart () [0x0000b] in <1170fb08300b4d0db71c1d1db8555768>:0
root@dev:/nas/terraria#

Here is a list of all of the things I've tried, in no particular order, and in different combinations each time (I've been trying for a very long time now):
  • Running as root
  • Ensuring all files under the 1403 folder have rwx
  • Ensuring the save folder location (~/.local/share/Terraria) has rwx
  • Running with the same config file that worked for 1305
  • Deleting all previous worlds
  • Ensuring there is enough RAM
  • Ensuring there is enough HDD space
  • Making sure it's the only process (outside of system processes) running on the machine
  • Running the TerrariaServer file
  • Running the TerrariaServer.bin.x86_64 file directly
  • Running the TerrariaServer.bin.x86 file directly
  • Running under different users (with different permissions)
Nothing I do seems to work, any ideas would be welcome at this point.
I'm aware I should not be running the server as root, however, that was mostly just for testing. Once it is working I will setup it's own user, home, and permissions like I had for my 1305 server.

Edit:
This is a vanilla server, no mods are included. It was downloaded straight for the home page through the "PC Dedicated Server" link.
 
Just been searching around for solutions to the same issue, no luck so far, just wanted to say it's happening to me as well.

Same situation, Ubuntu 18.04, only just started happening on v1.4.0.3's server bin.
Just the server crashing with "Thread creation failed" every time. ¯\_(ツ)_/¯
 
I’m having the same issue on AWS AMI Linux Kernel 4.14

Not an issue with importing a 1.4.0.2 world. Can’t create a new world either.

Had the same issue with TShock for 1.4.0.3
 
I am facing the same issue. The only solution I have had to even start this thing is with TShock, but that crashes on world gen.

My issue now is purely with the Vanilla server from the Official Terraria repository for them.
This is what happens when I run ./TerrariaServer after making everything executable.

I am on Ubuntu 20.04.

Unhandled Exception: System.TypeInitializationException: The type initializer for 'System.Console' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.ConsoleDriver' threw an exception. ---> System.Exception: Magic number is wrong: 542 at System.TermInfoReader.ReadHeader (System.Byte[] buffer, System.Int32& position) [0x0002b] in <1170fb08300b4d0db71c1d1db8555768>:0 at System.TermInfoReader..ctor (System.String term, System.String filename) [0x00065] in <1170fb08300b4d0db71c1d1db8555768>:0 at System.TermInfoDriver..ctor (System.String term) [0x00058] in <1170fb08300b4d0db71c1d1db8555768>:0 at System.ConsoleDriver.CreateTermInfoDriver (System.String term) [0x00000] in <1170fb08300b4d0db71c1d1db8555768>:0 at System.ConsoleDriver..cctor () [0x00062] in <1170fb08300b4d0db71c1d1db8555768>:0 --- End of inner exception stack trace --- at System.Console.SetupStreams (System.Text.Encoding inputEncoding, System.Text.Encoding outputEncoding) [0x0000a] in <1170fb08300b4d0db71c1d1db8555768>:0 at System.Console..cctor () [0x000a8] in <1170fb08300b4d0db71c1d1db8555768>:0 --- End of inner exception stack trace --- at Terraria.Utilities.CrashWatcher.Inititialize () [0x00000] in <1d95b9da8f7e4a9b96cec0bf3d2db575>:0 at Terraria.Program.SetupLogging () [0x0007d] in <1d95b9da8f7e4a9b96cec0bf3d2db575>:0 at Terraria.Program.LaunchGame (System.String[] args, System.Boolean monoArgs) [0x0006c] in <1d95b9da8f7e4a9b96cec0bf3d2db575>:0 at Terraria.LinuxLaunch.Main (System.String[] args) [0x00038] in <1d95b9da8f7e4a9b96cec0bf3d2db575>:0 [ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'System.Console' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.ConsoleDriver' threw an exception. ---> System.Exception: Magic number is wrong: 542 at System.TermInfoReader.ReadHeader (System.Byte[] buffer, System.Int32& position) [0x0002b] in <1170fb08300b4d0db71c1d1db8555768>:0 at System.TermInfoReader..ctor (System.String term, System.String filename) [0x00065] in <1170fb08300b4d0db71c1d1db8555768>:0 at System.TermInfoDriver..ctor (System.String term) [0x00058] in <1170fb08300b4d0db71c1d1db8555768>:0 at System.ConsoleDriver.CreateTermInfoDriver (System.String term) [0x00000] in <1170fb08300b4d0db71c1d1db8555768>:0 at System.ConsoleDriver..cctor () [0x00062] in <1170fb08300b4d0db71c1d1db8555768>:0 --- End of inner exception stack trace --- at System.Console.SetupStreams (System.Text.Encoding inputEncoding, System.Text.Encoding outputEncoding) [0x0000a] in <1170fb08300b4d0db71c1d1db8555768>:0 at System.Console..cctor () [0x000a8] in <1170fb08300b4d0db71c1d1db8555768>:0 --- End of inner exception stack trace --- at Terraria.Utilities.CrashWatcher.Inititialize () [0x00000] in <1d95b9da8f7e4a9b96cec0bf3d2db575>:0 at Terraria.Program.SetupLogging () [0x0007d] in <1d95b9da8f7e4a9b96cec0bf3d2db575>:0 at Terraria.Program.LaunchGame (System.String[] args, System.Boolean monoArgs) [0x0006c] in <1d95b9da8f7e4a9b96cec0bf3d2db575>:0 at Terraria.LinuxLaunch.Main (System.String[] args) [0x00038] in <1d95b9da8f7e4a9b96cec0bf3d2db575>:0

(EDIT: I should have said same issue as in crashing. I may be in the wrong thread cause clearly my crash is totally something else.)
 
I am facing the same issue. The only solution I have had to even start this thing is with TShock, but that crashes on world gen.

My issue now is purely with the Vanilla server from the Official Terraria repository for them.
This is what happens when I run ./TerrariaServer after making everything executable.

I am on Ubuntu 20.04.

Unhandled Exception: System.TypeInitializationException: The type initializer for 'System.Console' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.ConsoleDriver' threw an exception. ---> System.Exception: Magic number is wrong: 542 at System.TermInfoReader.ReadHeader (System.Byte[] buffer, System.Int32& position) [0x0002b] in <1170fb08300b4d0db71c1d1db8555768>:0 at System.TermInfoReader..ctor (System.String term, System.String filename) [0x00065] in <1170fb08300b4d0db71c1d1db8555768>:0 at System.TermInfoDriver..ctor (System.String term) [0x00058] in <1170fb08300b4d0db71c1d1db8555768>:0 at System.ConsoleDriver.CreateTermInfoDriver (System.String term) [0x00000] in <1170fb08300b4d0db71c1d1db8555768>:0 at System.ConsoleDriver..cctor () [0x00062] in <1170fb08300b4d0db71c1d1db8555768>:0 --- End of inner exception stack trace --- at System.Console.SetupStreams (System.Text.Encoding inputEncoding, System.Text.Encoding outputEncoding) [0x0000a] in <1170fb08300b4d0db71c1d1db8555768>:0 at System.Console..cctor () [0x000a8] in <1170fb08300b4d0db71c1d1db8555768>:0 --- End of inner exception stack trace --- at Terraria.Utilities.CrashWatcher.Inititialize () [0x00000] in <1d95b9da8f7e4a9b96cec0bf3d2db575>:0 at Terraria.Program.SetupLogging () [0x0007d] in <1d95b9da8f7e4a9b96cec0bf3d2db575>:0 at Terraria.Program.LaunchGame (System.String[] args, System.Boolean monoArgs) [0x0006c] in <1d95b9da8f7e4a9b96cec0bf3d2db575>:0 at Terraria.LinuxLaunch.Main (System.String[] args) [0x00038] in <1d95b9da8f7e4a9b96cec0bf3d2db575>:0 [ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'System.Console' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.ConsoleDriver' threw an exception. ---> System.Exception: Magic number is wrong: 542 at System.TermInfoReader.ReadHeader (System.Byte[] buffer, System.Int32& position) [0x0002b] in <1170fb08300b4d0db71c1d1db8555768>:0 at System.TermInfoReader..ctor (System.String term, System.String filename) [0x00065] in <1170fb08300b4d0db71c1d1db8555768>:0 at System.TermInfoDriver..ctor (System.String term) [0x00058] in <1170fb08300b4d0db71c1d1db8555768>:0 at System.ConsoleDriver.CreateTermInfoDriver (System.String term) [0x00000] in <1170fb08300b4d0db71c1d1db8555768>:0 at System.ConsoleDriver..cctor () [0x00062] in <1170fb08300b4d0db71c1d1db8555768>:0 --- End of inner exception stack trace --- at System.Console.SetupStreams (System.Text.Encoding inputEncoding, System.Text.Encoding outputEncoding) [0x0000a] in <1170fb08300b4d0db71c1d1db8555768>:0 at System.Console..cctor () [0x000a8] in <1170fb08300b4d0db71c1d1db8555768>:0 --- End of inner exception stack trace --- at Terraria.Utilities.CrashWatcher.Inititialize () [0x00000] in <1d95b9da8f7e4a9b96cec0bf3d2db575>:0 at Terraria.Program.SetupLogging () [0x0007d] in <1d95b9da8f7e4a9b96cec0bf3d2db575>:0 at Terraria.Program.LaunchGame (System.String[] args, System.Boolean monoArgs) [0x0006c] in <1d95b9da8f7e4a9b96cec0bf3d2db575>:0 at Terraria.LinuxLaunch.Main (System.String[] args) [0x00038] in <1d95b9da8f7e4a9b96cec0bf3d2db575>:0

(EDIT: I should have said same issue as in crashing. I may be in the wrong thread cause clearly my crash is totally something else.)

There seems to be a fix for this, looking around the Mono github, you should be able to set the environment variable "TERM" to xterm. Here is the github issue thread about it: System.TypeInitializationException: The type initializer for 'System.Console' threw an exception · Issue #8454 · mono/mono Seems the issue is related to outdated mono libraries, the primary difference between you and the rest of us is Ubuntu 20.04, so this might solve it for you.
 
It appears that the use or implementation of native threads in the bundled Mono version is not quite right.

With 1.4.0.2 there was a segfault when quitting and the backup done when saving the world could make it hang, now with 1.4.0.3 it just throws the unhandled exception from OP when starting.

I wonder if it can be made to run with system Mono libraries somehow, as locally installed packages are bound to be newer in virtually any case.
Just haven't dealt a lot with Mono so far.
 
I think I might've done something real dumb, but my 1403 server is running now.

I had an issue from 1401 onward, where every time I tried to use backspace in the server command line the server would crash - which is a separate issue, but still - and I can only guess that there's some sort of version-based lock it engages (maybe a library being used somewhere?) which a crashed server would not release. At first I thought it might be a world file lock, but as OP said, new world didn't work for them either.

I tried restarting my 1402 to see if I could just play on that the other day, tho never did, but left it running.

Today upon revisiting this issue I realised I'd left the 1402 server open, so closed it properly via "exit" (server command, not linux terminal) and then started 1403, just to grab the error message - and it was fine.

TLDR;
It might be worth checking that any previous versions of the server that were used - even if they're not running now - are started first if not running, and then properly shut down, then retrying 1403.

Might be a slightly separate issue if you came from using a pre-1.4 server to 1403, but this has seemingly fixed my jump from 1402 to 1403. Worth a shot? :dryadgrin:
 
I think I might've done something real dumb, but my 1403 server is running now.

I had an issue from 1401 onward, where every time I tried to use backspace in the server command line the server would crash - which is a separate issue, but still - and I can only guess that there's some sort of version-based lock it engages (maybe a library being used somewhere?) which a crashed server would not release. At first I thought it might be a world file lock, but as OP said, new world didn't work for them either.

I tried restarting my 1402 to see if I could just play on that the other day, tho never did, but left it running.

Today upon revisiting this issue I realised I'd left the 1402 server open, so closed it properly via "exit" (server command, not linux terminal) and then started 1403, just to grab the error message - and it was fine.

TLDR;
It might be worth checking that any previous versions of the server that were used - even if they're not running now - are started first if not running, and then properly shut down, then retrying 1403.

Might be a slightly separate issue if you came from using a pre-1.4 server to 1403, but this has seemingly fixed my jump from 1402 to 1403. Worth a shot? :dryadgrin:

Are you using linux to run your server? I tried to follow your example, but it still did not work for me.
 
Are you using linux to run your server? I tried to follow your example, but it still did not work for me.

I am yes, Ubuntu 18.04, but I don't know if it's just some fluke that I can now run it or if that was what fixed it. I didn't redownload the server software, update anything else (to my knowledge) that changed the situation, after everything I'd already tried, restarting and save-closing the old version was the only thing I believe I did.

Sorry to hear it didn't help your situation though :(
 
I had the same error message and just fixed it today -- it turns out I still had a tModLoaderServer process that was bound to port 7777, running in a different 'screen' session. Once I quit that process, my 1.4.0.3 server software started successfully.

As root, if you run this command, you can see if process is listening on port :7777

Wishing you luck that it's the same fix.

# netstat -ntpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:7777 0.0.0.0:* LISTEN 31608/TerrariaServe

# lsb_release -a
Description: Ubuntu 14.04.5 LTS
Release: 14.04
Codename: trusty
 
I had the same error message and just fixed it today -- it turns out I still had a tModLoaderServer process that was bound to port 7777, running in a different 'screen' session. Once I quit that process, my 1.4.0.3 server software started successfully.

As root, if you run this command, you can see if process is listening on port :7777

Wishing you luck that it's the same fix.

# netstat -ntpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:7777 0.0.0.0:* LISTEN 31608/TerrariaServe

# lsb_release -a
Description: Ubuntu 14.04.5 LTS
Release: 14.04
Codename: trusty
This did the trick! Thanks. In my case TMUX resumed sessions automatically, causing it to continue running the old 1305 world!
 
Back
Top Bottom