SignatureBeef / Terraria-s-Dedicated-Server-Mod

TDSM - .NET and Mono compatible Terraria Server Software Mod
MIT License
143 stars 49 forks source link

Crash on startup when using mono on Raspbian #219

Closed Dipricyn closed 8 years ago

Dipricyn commented 8 years ago

When I try to set up a Terraria server on my Raspberry Pi 2 using the following comand from a terminal the application crashes with the following message: Command: mono --runtime=v4.0.30319 ./TerrariaServer.exe Error message:

pi@dipripi:~/Terraria-s-Dedicated-Server-Mod/Binaries $ mono --runtime=v4.0.30319 ./TerrariaServer.exe
Missing method .ctor in assembly /home/pi/Terraria-s-Dedicated-Server-Mod/Binaries/TerrariaServer.exe, type System.Runtime.CompilerServices.ExtensionAttribute
Can't find custom attr constructor image: /home/pi/Terraria-s-Dedicated-Server-Mod/Binaries/TerrariaServer.exe mtoken: 0x0a000228
* Assertion at class.c:5597, condition `!mono_loader_get_last_error ()' not met

Stacktrace:

Native stacktrace:

Debug info from gdb:

[New LWP 4219]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
0x76e1fee8 in __libc_waitpid (Cannot access memory at address 0x41
pid=4220, stat_loc=0x7ecf95d0, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:40
40      ../sysdeps/unix/sysv/linux/waitpid.c: No such file or directory.
  Id   Target Id         Frame
  2    Thread 0x769c3430 (LWP 4219) "mono" 0x76e1da40 in do_futex_wait (isem=isem@entry=0x3181a4) at ../nptl/sysdeps/unix/sysv/linux/sem_wait.c:48
* 1    Thread 0x76f2e000 (LWP 4218) "mono" 0x76e1fee8 in __libc_waitpid (Cannot access memory at address 0x41
pid=4220, stat_loc=0x7ecf95d0, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:40

Thread 2 (Thread 0x769c3430 (LWP 4219)):
#0  0x76e1da40 in do_futex_wait (isem=isem@entry=0x3181a4) at ../nptl/sysdeps/unix/sysv/linux/sem_wait.c:48
#1  0x76e1daf4 in __new_sem_wait (sem=0x3181a4) at ../nptl/sysdeps/unix/sysv/linux/sem_wait.c:69
#2  0x00219f98 in mono_sem_wait ()
#3  0x0019091c in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Thread 1 (Thread 0x76f2e000 (LWP 4218)):
Cannot access memory at address 0x41
#0  0x76e1fee8 in __libc_waitpid (pid=4220, stat_loc=0x7ecf95d0, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:40
#1  0x000c0ba4 in ?? ()
Cannot access memory at address 0x41
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================

Aborted

I just cloned the git repository onto my file system but I also tried release build 005. Probably I am doing something wrong or mono for Raspbian isn't quite working (I installed mono-complete for Raspian Jessie which supports .NET 4.0 but I also tried other versions of mono).

SignatureBeef commented 8 years ago

Hi @Dipricyn

What mono version are you running? mono -V

I haven't actually had a chance to test on rpi's. The old builds I can nearly guarantee will crash and burn due to memory. However, the files you currently have from the repo might have a decent chance as memory is heavily reduced thanks to OTAPI.

Dipricyn commented 8 years ago

Thanks for your reply @DeathCradle

pi@dipripi:~ $ mono --version
Mono JIT compiler version 3.2.8 (Debian 3.2.8+dfsg-10)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           __thread
        SIGSEGV:       normal
        Notifications: epoll
        Architecture:  armel,vfp+hard
        Disabled:      none
        Misc:          softdebug
        LLVM:          supported, not enabled.
        GC:            sgen

The new Raspberry Pi 2 has 1GB of RAM. I think the RAM could be enough as the vanilla Terraria server for Windows takes around 520MB of memory on my system.

SignatureBeef commented 8 years ago

Hi @Dipricyn

I only have a Rpi B+ available to me, but I can confirm TDSM seems to be having issues (i'll work on this shortly). I wasn't able to replicate the same issue, rather a worse one.

However, I have actually had success running a bare OTAPI install. It uses about 350/400mb for a small world (mono has more overhead). Since world gen requires more memory, I didn't have enough to test generation, so I had to generate a world on another machine. In the end, the server loaded the world with about 30mb to spare on the system - so your v2 should have no problem here (both memory and performance).

Would it be cool to ask if I could get you to grab a [Server] build .zip from https://openterraria.com/bleeding-edge and report back as to if that works for you?

Dipricyn commented 8 years ago

Hello @DeathCradle I am glad to help. So I downloaded this file (I hope it is the correct version): wget https://openterraria.com/builds/Linux/Linux-cd437ba1de1a7e237163a4f17fa90eb8a09a09d2.zip and I installed mono-complete after I installed a fresh version of Raspbian. Executing the server start script gave me:

pi@raspberrypi:~/ltapi/Binaries $ ./start-server.sh
Cannot open assembly 'TerrariaServer.exe': No such file or directory.
Restarting server...

Because of that I tried to start the server by doing this:

pi@raspberrypi:~/ltapi/Binaries $ sudo mono ./Server/TerrariaServer.exe 

[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: An exception was thrown by the type initializer for OTA.Tools ---> System.TypeInitializationException: An exception was thrown by the type initializer for Terraria.Main ---> System.IO.FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies.
File name: 'Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
  --- End of inner exception stack trace ---
  --- End of inner exception stack trace ---
  at OTA.Callbacks.MainCallback.ProgramStart () [0x00000] in <filename unknown>:0 
  at OTA.Callbacks.MainCallback.OnProgramStarted (System.String[] cmd) [0x00000] in <filename unknown>:0 
  at Terraria.WindowsLaunch.Main (System.String[] args) [0x00000] in <filename unknown>:0 
pi@raspberrypi:~/ltapi/Binaries $ 

Unfortunately this led to another error about missing dependenc

SignatureBeef commented 8 years ago

@Dipricyn

Sorry, I should have been more clear (or had instructions on the site) - it's all new.

You need the server build, as the Linux Mac and Windows builds are for client versions of otapi.

When you get the server build, whilst in the Binaries folder, copy the contents of Server back into Binaries (cp Server/* .) This is because our patcher will put the specific builds in their own folder within Binaries - so I might have this changed in future so it's a bit easier.

Dipricyn commented 8 years ago

@DeathCradle Thanks, for making it more clear! After I copied the server files to the Binaries directory the server runs fine, but I will need to test out how many enemies and projectiles it can handle. After the server wasn't shut down properly I got the following message and it suspended at the last line:

Terraria Server v1.3.0.8

16/02/2016 17:27:01 Pool Info> Creating tile array of 8400x2400, 249MB
16/02/2016 17:27:20 Pool Info> Creating tile array of 8400x2400, 249MB
16/02/2016 17:27:20 Pool Info> Load failed!  No backup found.
16/02/2016 17:27:20 Run Info> Resetting game objects 1%

One other time I had to copy the server files to the Binaries folder because it showed this error: Couldn't open assemble TerrariaServer.exe because it doensn't contain a valid CIL image. But all in all this version is working.

SignatureBeef commented 8 years ago

@Dipricyn that's great news! I have also fixed an issue regarding TDSMs' patcher while updating the Binaries files. I didn't receive the exact same exception as you, however it could be related as the OTA.dll / TerrariaServer.exe may not have been compatible with each other.

If you still require TDSM, are you able to grab the latest GitHub repo zip and give it a whirl when you get a chance?

Dipricyn commented 8 years ago

I don't require TDSM anymore but I tried it anyway. Now it works fine. Thanks for solving the issue.