[Mono-osx] Problem with loading OSX libc ( malloc)

Paolo Molaro lupus at ximian.com
Tue Oct 10 10:54:49 EDT 2006

On 10/10/06 Eoin Norris wrote:
> Downloaded some SQLite sources from the good people at Finisar, and  
> compiled.  I get however an exception like this on run.
>   The exception is   at (wrapper managed-to-native)  
> Finisar.SQLite.Util:malloc (uint)
>    at Finisar.SQLite.Util.AllocateUnmanagedMemory (Int32 size) [0x00000]
>    at Finisar.SQLite.MarshalStr.GetSQLiteStr () [0x00000]
>    at Finisar.SQLite.sqlite3.open (System.String filename) [0x00000]
>    at Finisar.SQLite.SQLiteConnection.Open () [0x00000]
> Finisar imports the libc as so
> [DllImport("libc")]
> private extern static IntPtr malloc(UInt32 bytes);
> and calls it like so
> 	public static IntPtr AllocateUnmanagedMemory( Int32 size )
> 		{
> 			if( (int)Environment.OSVersion.Platform == UNIX )
> 				return malloc((UInt32)1000);
> 			else
> 				return HeapAlloc( GetProcessHeap(), 0, (UInt32)size );
> 		}
>   Anybody got any ideas? ( note it does seem to load the SQLLite3  
> library - which is in /lib/bin/ because an db, if empty, is created  
> before I get an exception)

It looks like you don't have the mono config file properly installed or
some other local issue.
The file should be named config and placed in the $prefix/etc/mono
directory. The contents should be something like:
        <dllmap dll="cygwin1.dll" target="libc.dylib" />
        <dllmap dll="libc" target="libc.dylib" />
        <dllmap dll="intl" target="libintl.dylib" />
        <dllmap dll="libintl" target="libintl.dylib" />
        <dllmap dll="libxslt.dll" target="libxslt.dylib" />
        <dllmap dll="libmySQL.dll" target="libmysqlclient.dylib" />
        <dllmap dll="odbc32.dll" target="libodbc.dylib" />
        <dllmap dll="oci" target="libclntsh.dylib" />
        <dllmap dll="db2cli" target="libdb2_36.dylib" />
        <dllmap dll="msvcrt" target="libc.dylib" />
        <dllmap dll="MonoPosixHelper" target="libMonoPosixHelper.dylib"
        <dllmap dll="sqlite" target="libsqlite.0.dylib" />
        <dllmap dll="sqlite3" target="libsqlite3.0.dylib" />
        <dllmap dll="libX11" target="libX11.dylib" />
        <dllmap dll="libcairo-2.dll" target="libcairo.so.2" />

You could also add one specific to the dll you have, as detailed in man
mono-config. For Finisar.SQLite.dll you'd have a file named
Finisar.SQLite.dll.config in the same directory with the following
        <dllmap dll="libc" target="libc.dylib" />

You can also get a more detailed error report with:
MONO_LOG_LEVEL="debug" MONO_LOG_MASK="dll" mono prog.exe

Paste the result if it still won't work for you.


lupus at debian.org                                     debian/rules
lupus at ximian.com                             Monkeys do it better

More information about the Mono-osx mailing list