[Mono-bugs] [Bug 698127] New: Mono.Data.Sqlite. dll doesn’t work on Mac OS X 10 .5

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sat Jun 4 09:41:50 EDT 2011



           Summary: Mono.Data.Sqlite.dll doesn’t work on Mac OS X 10.5
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.10.x
          Platform: x86
        OS/Version: Mac OS X 10.5
            Status: NEW
          Severity: Major
          Priority: P5 - None
         Component: Mono.Data.Sqlite
        AssignedTo: mhabersack at novell.com
        ReportedBy: vyacheslav.com at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: Third Party Developer/Partner
           Blocker: Yes

Description of Problem:

Any code, that uses Mono.Data.Sqlite.dll gets exception when attempts to open
SQLite db. Example of such code could be found here:


This problem also rises when launching MonoTouch applications on Mac OS X 10.5
and is documented here (and on different forums):


That bug is closed, but documentation here:


States, that fix will be released in future and for now Snow Leopard should be
used, which could be appropriate for iOS development, but not for Mac OS
support. And the problem is specific to Mono, not MonoTouch, as far as I can

So, Mono.Data.Sqlite.dll imports SQLite3 library as sqlite3, which is mapped to
/Library/Frameworks/Mono.framework/Versions/2.10.2/lib/libsqlite3.0.dylib in
Mono's config file.

When test applications is launched with MONO_LOG_LEVEL=debug in command line,
log shows, that dllmap resolutions works correctly and mono_lookup_pinvoke_call
in mono\metadata\loader.c (line ~1251) tries to load correct library:

Mono: DllImport attempting to load:

Next code in loader.c (lines ~1370-1371):

char *mdirname = g_path_get_dirname (image->name);
while ((full_name = mono_dl_build_path (mdirname, file_name, &iter))) {

Combines directory path of Mono.Data.Sqlite.dll and full path to Mono's version
of libsqlite3.0.dylib and tries to load result via cached_module_load;
corresponding log item:

Mono: DllImport loading library:

Somehow that call succeeds, but loads /usr/lib/libsqlite3.0.dylib. That library
on Mac OS X 10.5 has version 3.4.0 and this causes exception to be thrown by
Mono.Data.Sqlite.dll code:

Your sqlite3 version is old - please upgrade to at least v3.5.0!
System.EntryPointNotFoundException: sqlite3_next_stmt
  at (wrapper managed-to-native)
Mono.Data.Sqlite.UnsafeNativeMethods:sqlite3_next_stmt (intptr,intptr)
  at Mono.Data.Sqlite.SQLiteBase.ResetConnection
(Mono.Data.Sqlite.SqliteConnectionHandle db) [0x00000] in <filename unknown>:0 
  at Mono.Data.Sqlite.SQLiteBase.CloseConnection
(Mono.Data.Sqlite.SqliteConnectionHandle db) [0x00000] in <filename unknown>:0 
  at Mono.Data.Sqlite.SqliteConnectionHandle.ReleaseHandle () [0x00000] in
<filename unknown>:0 
  at System.Runtime.InteropServices.CriticalHandle.Dispose (Boolean disposing)
[0x00000] in <filename unknown>:0 
  at System.Runtime.InteropServices.CriticalHandle.Dispose () [0x00000] in
<filename unknown>:0 
  at Mono.Data.Sqlite.SQLite3.Close () [0x00000] in <filename unknown>:0 
  at Mono.Data.Sqlite.SqliteConnection.Close () [0x00000] in <filename
  at Mono.Data.Sqlite.SqliteConnection.Open () [0x00000] in <filename
  at SqliteMonoTest.Program.Main (System.String[] args) [0x00000] in <filename

On Mac OS x 10.6 that exceptions is not thrown, since
/usr/lib/libsqlite3.0.dylib is newer and it hides the problem, but does not fix

Tried to change *LD_LIBRARY_PATH env variables, change current directory,
manually loading libsqlite3.0.dylib from Mono’s lib folder via dlopen - same

Steps to reproduce the problem:
1. Run sample app from monotouch site (link above).
2. Additionally, catch exception in Main method of that code and add next lines
after catch block:

ProcessModuleCollection modules = Process.GetCurrentProcess().Modules;
foreach (ProcessModule module in modules)
    Console.WriteLine("[{0}]: {1}", module.ModuleName, module.FileName);

To see, that /usr/lib/libsqlite3.0.dylib is loaded:

[mono]: /usr/bin/mono
[libSystem.B.dylib]: /usr/lib/libSystem.B.dylib
[libiconv.2.dylib]: /usr/lib/libiconv.2.dylib
[libgcc_s.1.dylib]: /usr/lib/libgcc_s.1.dylib
[libicucore.A.dylib]: /usr/lib/libicucore.A.dylib
[libobjc.A.dylib]: /usr/lib/libobjc.A.dylib
[libauto.dylib]: /usr/lib/libauto.dylib
[libstdc++.6.dylib]: /usr/lib/libstdc++.6.dylib
[libmathCommon.A.dylib]: /usr/lib/system/libmathCommon.A.dylib
[libsqlite3.0.dylib]: /usr/lib/libsqlite3.0.dylib 

3. Run app with MONO_LOG_LEVEL=debug to see above log messages.

How often does this happen? 

Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

More information about the mono-bugs mailing list