문제

I'm attempting to use mono run the C# Server Application of the KMP multiplayer mod (development builds can be found here), which comes with an included sqlite3.dll library.

However after running the server for a few minutes with more than one client connected, the server application will crash with the following Stacktrace:

Stacktrace:

  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) System.Data.SQLite.UnsafeNativeMethods.sqlite3_prepare_v2 (intptr,intptr,int,intptr&,intptr&) <0xffffffff>
  at System.Data.SQLite.SQLite3.Prepare (System.Data.SQLite.SQLiteConnection,string,System.Data.SQLite.SQLiteStatement,uint,string&) <0x003f3>
  at System.Data.SQLite.SQLiteCommand.BuildNextCommand () <0x001eb>
  at System.Data.SQLite.SQLiteCommand.GetStatement (int) <0x00023>
  at (wrapper remoting-invoke-with-check) System.Data.SQLite.SQLiteCommand.GetStatement (int) <0xffffffff>
  at System.Data.SQLite.SQLiteDataReader.NextResult () <0x0031f>
  at System.Data.SQLite.SQLiteDataReader..ctor (System.Data.SQLite.SQLiteCommand,System.Data.CommandBehavior) <0x00177>
  at (wrapper remoting-invoke-with-check) System.Data.SQLite.SQLiteDataReader..ctor (System.Data.SQLite.SQLiteCommand,System.Data.CommandBehavior) <0xffffffff>
  at System.Data.SQLite.SQLiteCommand.ExecuteReader (System.Data.CommandBehavior) <0x00047>
  at System.Data.SQLite.SQLiteCommand.ExecuteNonQuery () <0x00027>
  at KMPServer.Server.HandleUDPProbe (KMPServer.Client,byte[]) <0x00318>
  at KMPServer.Server.handleMessage (KMPServer.Client,KMPCommon/ClientMessageID,byte[]) <0x0022f>
  at KMPServer.Server.asyncUDPReceive (System.IAsyncResult) <0x0035f>
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void__this___object (object,intptr,intptr,intptr) <0xffffffff>

And here it is including the native gbd stacktrace: https://gist.github.com/CarnotInteractive/cba680da54e05ad7f940


It seems that somewhere in the UDP code, the SQLite library crashes, which does not happen when running the same code on windows.

The mod's developers have suggested trying to find a different sqlite3 binding or library, but even after downloading the sqlite source code, compiling it on my Mac and then using the resulting "libsqlite3.0.dylib" library I still get this error.

Is it possible that this is an issue with Mono directly? What might be causing this issue, and how could this be fixed?

도움이 되었습니까?

해결책

Running mono with the following debug variables:

export MONO_LOG_LEVEL=debug;
export MONO_LOG_MASK=dll; 

I was able to figure out that although mono was able to see my compiled dylib, it was not loading it, stating that it was the wrong architecture.

The Server executable file is 32bit and when compiling sqlite from source with just ./configure, the resulting library is only 64bit.

I then tried to compile it for 32bit only:

CFLAGS='-arch i686' LDFLAGS='-arch i686' ./configure --disable-dependency-tracking;
make;

The resulting dylib is loaded correctly and seems to have fixed the problem. I no longer get the same crash as I had before.


In summary, it seems that, for whatever reason, the default mac sqlib located at /usr/lib/libsqlite3.dylib causes a crash with mono and the executable I was attempting to run. Compiling my own 32 bit version fixed the issue.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top