[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


https://bugzilla.novell.com/show_bug.cgi?id=698127

https://bugzilla.novell.com/show_bug.cgi?id=698127#c0


           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:

http://monotouch.net/Documentation/System.Data#Example

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

https://bugzilla.novell.com/show_bug.cgi?id=555946

That bug is closed, but documentation here:

http://monotouch.net/Documentation/Troubleshoot

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
see.

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:
'/Library/Frameworks/Mono.framework/Versions/2.10.2/lib/libsqlite3.0.dylib'.

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:
'/Library/Frameworks/Mono.framework/Versions/2.10.2/lib/mono/gac/Mono.Data.Sqlite/2.0.0.0__0738eb9f132ed756/lib/Library/Frameworks/Mono.framework/Versions/2.10.2/lib/libsqlite3.0.dylib'.

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
unknown>:0 
  at Mono.Data.Sqlite.SqliteConnection.Open () [0x00000] in <filename
unknown>:0 
  at SqliteMonoTest.Program.Main (System.String[] args) [0x00000] in <filename
unknown>:0  

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
it.

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

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
[CoreFoundation]:
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
[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? 
Always.

-- 
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