Bug 1383 - App crashes when making a sqlite connection
Summary: App crashes when making a sqlite connection
Status: RESOLVED INVALID
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 4.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Sebastien Pouliot
URL:
Depends on:
Blocks:
 
Reported: 2011-10-09 14:21 UTC by James Scheibel
Modified: 2011-10-11 11:50 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
entire project with binaries that produces the error (5.28 MB, application/zip)
2011-10-10 00:06 UTC, James Scheibel
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED INVALID

Description James Scheibel 2011-10-09 14:21:00 UTC
When I launch a program in the debugger it blows up the moment it runs .open() on a connection. this has happened since I upgraded to 4.2.2 (and 4.2 - which i skipped cause I saw the error and waited a version) the last release I was using that it worked on was 4.0.x series. (i don't normally run the betas so I cant speak to those)

My machine is
  Model Name:	Mac mini
  Model Identifier:	Macmini2,1
  Processor Name:	Intel Core 2 Duo
  Processor Speed:	1.83 GHz
  Number Of Processors:	1
  Total Number Of Cores:	2
  L2 Cache:	2 MB
  Memory:	3 GB
  Bus Speed:	667 MHz
  Boot ROM Version:	MM21.009A.B00
  SMC Version (system):	1.19f2
I am running snow leopard version 10.6.8.

To reproduce the bug do the following: create a new empty project in monotouch in monodevelop. Add a mono.data.sqlite reference to the project (my reference is to version 2.0.5.0). add a sqlite database to the file system (so it can be accessed). set it to copy if newer and set it as content

code to reproduce is as follows

using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using Mono.Data.Sqlite;
using System.IO;

namespace ErrorExample
{
	[Register ("AppDelegate")]
	public partial class AppDelegate : UIApplicationDelegate
	{
		// class-level declarations
		UIWindow window;
	
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{
			// create a new window instance based on the screen size
			window = new UIWindow (UIScreen.MainScreen.Bounds);
						
			// make the window visible
			window.MakeKeyAndVisible ();
								
			//copy new version over
			File.Copy("./Data/example.sqlite","../Documents/example.sqlite",true);
		
			//clean install
			SqliteConnection dbconnOld = new SqliteConnection("URI=file:../Documents/example.sqlite;version=3;busy_timeout=3000");
			dbconnOld.Open();	
			dbconnOld.Close();
			return true;
		}
	}
}


the application output is:

Launching application
Application launched. PID = 9760
Loaded assembly: /Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll [External]
Loaded assembly: /Developer/MonoTouch/usr/lib/mono/2.1/System.Core.dll [External]
Loaded assembly: /Developer/MonoTouch/usr/lib/mono/2.1/System.dll [External]
Loaded assembly: /Users/j_scheibel/Projects/ErrorExample/ErrorExample/bin/iPhoneSimulator/Debug/ErrorExample.exe
Loaded assembly: /Developer/MonoTouch/usr/lib/mono/2.1/Mono.Data.Sqlite.dll [External]
Loaded assembly: /Developer/MonoTouch/usr/lib/mono/2.1/System.Data.dll [External]
Loaded assembly: /Developer/MonoTouch/usr/lib/mono/2.1/System.Transactions.dll [External]
Loaded assembly: /Developer/MonoTouch/usr/lib/mono/2.1/Mono.Data.Tds.dll [External]
Loaded assembly: /Developer/MonoTouch/usr/lib/mono/2.1/Mono.Security.dll [External]
Loaded assembly: /Developer/MonoTouch/usr/lib/mono/2.1/System.Xml.dll [External]
Detected an attempt to call a symbol in system libraries that is not present on the iPhone:
pthread_mutexattr_destroy$UNIX2003 called from function pthreadMutexAlloc in image libsqlite3.dylib.
If you are encountering this problem running a simulator binary within gdb, make sure you 'set start-with-shell off' first.
Stacktrace:

  at (wrapper managed-to-native) Mono.Data.Sqlite.UnsafeNativeMethods.sqlite3_open_v2 (byte[],intptr&,int,intptr) <IL 0x0003b, 0xffffffff>
  at Mono.Data.Sqlite.SQLite3.Open (string,Mono.Data.Sqlite.SQLiteOpenFlagsEnum,int,bool) [0x00040] in /Developer/MonoTouch/Source/mono/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLite3.cs:129
  at Mono.Data.Sqlite.SqliteConnection.Open () [0x0021a] in /Developer/MonoTouch/Source/mono/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLiteConnection.cs:876
  at ErrorExample.AppDelegate.FinishedLaunching (MonoTouch.UIKit.UIApplication,MonoTouch.Foundation.NSDictionary) [0x0003b] in /Users/j_scheibel/Projects/ErrorExample/ErrorExample/AppDelegate.cs:30
  at (wrapper runtime-invoke) <Module>.runtime_invoke_bool__this___object_object (object,intptr,intptr,intptr) <IL 0x00066, 0xffffffff>
  at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <IL 0x0009f, 0xffffffff>
  at MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x00042] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:29
  at ErrorExample.Application.Main (string[]) [0x00000] in /Users/j_scheibel/Projects/ErrorExample/ErrorExample/Main.cs:16
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>

Native stacktrace:

	0   ErrorExample                        0x000d1e9c mono_handle_native_sigsegv + 343
	1   ErrorExample                        0x0013c3ea sigabrt_signal_handler + 116
	2   libSystem.host.dylib                0x02b9d05b _sigtramp + 43
	3   ???                                 0xffffffff 0x0 + 4294967295
	4   libSystem.host.dylib                0x02c2a5a5 raise + 26
	5   libSystem.host.dylib                0x02c406e4 abort + 93
	6   libSystem.dylib                     0x029d3548 __springboard_unimplemented + 376
	7   libSystem.dylib                     0x029dd711 pthread_mutexattr_destroy$UNIX2003 + 45
	8   libsqlite3.dylib                    0x0d40a6af pthreadMutexAlloc + 207
	9   libsqlite3.dylib                    0x0d406dec sqlite3_initialize + 2060
	10  libsqlite3.dylib                    0x0d445e0d openDatabase + 29
	11  ???                                 0x0d3ef4e7 0x0 + 222229735
	12  ???                                 0x0d3ed7cc 0x0 + 222222284
	13  ???                                 0x0cfec10a 0x0 + 218022154
	14  ???                                 0x0cfe86a4 0x0 + 218007204
	15  ???                                 0x0cfe88a5 0x0 + 218007717
	16  ErrorExample                        0x0000fe9b mono_jit_runtime_invoke + 1332
	17  ErrorExample                        0x001ee961 mono_runtime_invoke + 137
	18  ErrorExample                        0x0029f964 monotouch_trampoline + 2527
	19  UIKit                               0x01d151fa -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1163
	20  UIKit                               0x01d1755e -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 439
	21  UIKit                               0x01d21db2 -[UIApplication handleEvent:withNewEvent:] + 1533
	22  UIKit                               0x01d1a202 -[UIApplication sendEvent:] + 71
	23  UIKit                               0x01d1f732 _UIApplicationHandleEvent + 7576
	24  GraphicsServices                    0x0453ca36 PurpleEventCallback + 1550
	25  CoreFoundation                      0x00f2c064 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
	26  CoreFoundation                      0x00e8c6f7 __CFRunLoopDoSource1 + 215
	27  CoreFoundation                      0x00e89983 __CFRunLoopRun + 979
	28  CoreFoundation                      0x00e89240 CFRunLoopRunSpecific + 208
	29  CoreFoundation                      0x00e89161 CFRunLoopRunInMode + 97
	30  UIKit                               0x01d16fa8 -[UIApplication _run] + 636
	31  UIKit                               0x01d2342e UIApplicationMain + 1160
	32  ???                                 0x0a2cc51d 0x0 + 170706205
	33  ???                                 0x0a2cad50 0x0 + 170700112
	34  ???                                 0x0a2caa48 0x0 + 170699336
	35  ???                                 0x0a2cab9e 0x0 + 170699678
	36  ErrorExample                        0x0000fe9b mono_jit_runtime_invoke + 1332
	37  ErrorExample                        0x001ee961 mono_runtime_invoke + 137
	38  ErrorExample                        0x001f1048 mono_runtime_exec_main + 669
	39  ErrorExample                        0x001f0432 mono_runtime_run_main + 843
	40  ErrorExample                        0x000a3f9e mono_jit_exec + 200
	41  ErrorExample                        0x002a3d21 main + 3733
	42  ErrorExample                        0x00003179 _start + 208
	43  ErrorExample                        0x000030a8 start + 40

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


by adding break points to find the exact line it blows up on you find that the error occurs on line 30 dbconnOld.Open();

Let me know if there is any other information I can provide.
Comment 1 Sebastien Pouliot 2011-10-09 20:03:39 UTC
4.0.x used a different build system so maybe we're missing a #define somewhere (still weird that it works for so many other people). I'll look into this possibility...

In the mean time could you tell me if this happens on the simulator, device or both ?

Also could you attach your Data/example.sqlite file ? it's simpler (for me) and also ensure I'll be testing the exact same thing as you are. Thanks!
Comment 2 James Scheibel 2011-10-09 23:53:07 UTC
It appears to be only in the simulator. (I honestly hadn't tried a device till you asked.) I'm attaching the entire project with the binaries so you will have everything and then some
Comment 3 James Scheibel 2011-10-10 00:06:53 UTC
Created attachment 654 [details]
entire project with binaries that produces the error
Comment 4 Sebastien Pouliot 2011-10-10 10:13:57 UTC
Weird but your sample code works fine here.

a. Can you confirm me your MonoTouch version ? 

in a terminal window do the following command:
/Developer/MonoTouch/usr/bin/mtouch --version

you can also add the following line at the beginning of your FinishedLaunching method
	Console.WriteLine (MonoTouch.Constants.Version);


b. Also can you try to set your simulator (it's likely on Default) to "iPhone Simulator 4.3" ? 

in monodevelop select Project menu, iPhone Simulator Target, then "iPhone Simulator 4.3"
Comment 5 James Scheibel 2011-10-10 11:02:32 UTC
version information:
mtouch 4.2.2.1317158288

the console.writeline line blows up with this error:


Detected an attempt to call a symbol in system libraries that is not present on the iPhone:
fopen$UNIX2003 called from function locale_charset in image libiconv.2.dylib.
If you are encountering this problem running a simulator binary within gdb, make sure you 'set start-with-shell off' first.
Stacktrace:

  at (wrapper managed-to-native) System.Text.Encoding.InternalCodePage (int&) <IL 0x00021, 0xffffffff>
  at System.Console..cctor () [0x00019] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Console.cs:127
  at (wrapper runtime-invoke) object.runtime_invoke_void (object,intptr,intptr,intptr) <IL 0x0004c, 0xffffffff>
  at ErrorExample.AppDelegate.FinishedLaunching (MonoTouch.UIKit.UIApplication,MonoTouch.Foundation.NSDictionary) [0x00000] in /Users/j_scheibel/Projects/ErrorExample/ErrorExample/AppDelegate.cs:19
  at (wrapper runtime-invoke) <Module>.runtime_invoke_bool__this___object_object (object,intptr,intptr,intptr) <IL 0x00066, 0xffffffff>
  at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <IL 0x0009f, 0xffffffff>
  at MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x00042] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:29
  at ErrorExample.Application.Main (string[]) [0x00000] in /Users/j_scheibel/Projects/ErrorExample/ErrorExample/Main.cs:16
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>

Native stacktrace:

	0   ErrorExample                        0x000d1e9c mono_handle_native_sigsegv + 343
	1   ErrorExample                        0x0013c3ea sigabrt_signal_handler + 116
	2   libSystem.host.dylib                0x02b9d05b _sigtramp + 43
	3   ???                                 0xffffffff 0x0 + 4294967295
	4   libSystem.host.dylib                0x02c2a5a5 raise + 26
	5   libSystem.host.dylib                0x02c406e4 abort + 93
	6   libSystem.dylib                     0x029d3548 __springboard_unimplemented + 376
	7   libSystem.dylib                     0x029db251 fopen$UNIX2003 + 45
	8   libiconv.2.dylib                    0x0047d9b3 locale_charset + 330
	9   ErrorExample                        0x00286b3f monoeg_g_get_charset + 30
	10  ErrorExample                        0x0018cc61 ves_icall_System_Text_Encoding_InternalCodePage + 49
	11  ???                                 0x0d0db686 0x0 + 219002502
	12  ???                                 0x0d0db1e4 0x0 + 219001316
	13  ???                                 0x07790081 0x0 + 125370497
	14  ErrorExample                        0x0000fe9b mono_jit_runtime_invoke + 1332
	15  ErrorExample                        0x001ee961 mono_runtime_invoke + 137
	16  ErrorExample                        0x001e9373 mono_runtime_class_init_full + 1746
	17  ErrorExample                        0x0000f02b mono_jit_compile_method_inner + 3681
	18  ErrorExample                        0x0000f262 mono_jit_compile_method_with_opt + 513
	19  ErrorExample                        0x0000f3ec mono_jit_compile_method + 50
	20  ErrorExample                        0x001e9ce2 mono_compile_method + 73
	21  ErrorExample                        0x000d36c8 common_call_trampoline + 1910
	22  ErrorExample                        0x000d3bfd mono_magic_trampoline + 88
	23  ???                                 0x0773d066 0x0 + 125030502
	24  ???                                 0x0d0da8d5 0x0 + 218998997
	25  ErrorExample                        0x0000fe9b mono_jit_runtime_invoke + 1332
	26  ErrorExample                        0x001ee961 mono_runtime_invoke + 137
	27  ErrorExample                        0x0029f964 monotouch_trampoline + 2527
	28  UIKit                               0x01d151fa -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1163
	29  UIKit                               0x01d1755e -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 439
	30  UIKit                               0x01d21db2 -[UIApplication handleEvent:withNewEvent:] + 1533
	31  UIKit                               0x01d1a202 -[UIApplication sendEvent:] + 71
	32  UIKit                               0x01d1f732 _UIApplicationHandleEvent + 7576
	33  GraphicsServices                    0x0453ca36 PurpleEventCallback + 1550
	34  CoreFoundation                      0x00f2c064 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
	35  CoreFoundation                      0x00e8c6f7 __CFRunLoopDoSource1 + 215
	36  CoreFoundation                      0x00e89983 __CFRunLoopRun + 979
	37  CoreFoundation                      0x00e89240 CFRunLoopRunSpecific + 208
	38  CoreFoundation                      0x00e89161 CFRunLoopRunInMode + 97
	39  UIKit                               0x01d16fa8 -[UIApplication _run] + 636
	40  UIKit                               0x01d2342e UIApplicationMain + 1160
	41  ???                                 0x0a3ce51d 0x0 + 171762973
	42  ???                                 0x0a3ccd50 0x0 + 171756880
	43  ???                                 0x0a3cca48 0x0 + 171756104
	44  ???                                 0x0a3ccb9e 0x0 + 171756446
	45  ErrorExample                        0x0000fe9b mono_jit_runtime_invoke + 1332
	46  ErrorExample                        0x001ee961 mono_runtime_invoke + 137
	47  ErrorExample                        0x001f1048 mono_runtime_exec_main + 669
	48  ErrorExample                        0x001f0432 mono_runtime_run_main + 843
	49  ErrorExample                        0x000a3f9e mono_jit_exec + 200
	50  ErrorExample                        0x002a3d21 main + 3733
	51  ErrorExample                        0x00003179 _start + 208
	52  ErrorExample                        0x000030a8 start + 40
	53  ???                                 0x00000002 0x0 + 2

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

I don't have 4.3 as an option just 4.2 both in the simulator and in monodevelop . I tried changing changing it to default to 4.0 and 4.2 and it blows up.
Comment 6 Sebastien Pouliot 2011-10-10 11:24:19 UTC
It seems you're using the (old) 4.2 SDK which does not include some symbols that are part of the 4.3+ SDK. This cause a problem since the pre-compiled simlauncher-4 we ship requires the symbols (the old version of MonoTouch you were using was likely compiled/linked against the 4.2 SDK).

The workarounds are:

a) update to Apple iOS 4.3 SDK (or later)

b) do not use the pre-compiled simlauncher-4

for this you can add the following "extra mtouch arguments" in your project Options, "iPhone Build":

--gcc_flags "-L${ProjectDir}"

it will skip the simlauncher-fast-path and build it's own, app specific, application launcher (a bit longer to compile).

Note: this does not affect the device builds since the application launcher is always rebuilt in that case (since it needs to handle registration).
Comment 7 James Scheibel 2011-10-10 12:53:10 UTC
that all makes sense. I didn't realize there was a new sdk. But then, I'm not diligent about keeping track of when new SDKs come out. And even when I know, unless there is a new feature/fix I want I wont upgrade unless it's automatically done. I don't fix what isn't broken lest it break something. 

Something similar happened once before. I actually had another version of monotouch realize I hadn't upgraded the sdk and not offer the automatic upgrade to the new version. In that case someone had to do what you are doing now and tell me to upgrade my sdk (and buy snow leopard which it required). I needed that upgrade cause it fixed an issue with the database (i can't remember what). I guess next time this sort of thing happens that will be the first thing I go looking for.

Anyway, I'll do that tonight and let you know if that fixes everything. it sounds like it should.
Comment 8 James Scheibel 2011-10-11 00:51:39 UTC
I installed the new sdk and it did fix the problem. thanks!

(it's worth noting that for some reason installing the sdk blew away my monotouch install for some bizarre reason. I had to re-download it from the members area to get it to work. but it ended well in the end)
Comment 9 Sebastien Pouliot 2011-10-11 08:15:44 UTC
James, updating the SDK should not have caused any changein your MonoTouch setup. Maybe it was just MonoDevelop who did not find the new tools ? (unless restarted). Did you check if the MonoTouch directory still existed before the re-installing ?

Marking this issue as closed - but if you have any additional details about the SDK/MT mixup please fill a new bug report and include them. I'll make sure people working on the setup are made aware of it. Thanks!
Comment 10 James Scheibel 2011-10-11 11:50:10 UTC
ya, I don't know if it actually removed any monotouch stuff. I can't imagine why it would. It probably just confused monodevelop in some way. I can say that the license files were still there. but monodevelop acted like it wasn't installed. That is, no menu items related to monotouch and the project woudn't load as it didnt know know what the project type guids were. 

I closed the program and reopened. rebooted. nada. i ended up setting up my account at xarmarin.com (i had not migrated my account from novel yet so i needed to do this anyway I suppose) and getting the installer again. that fixed everything.
Comment 11 James Scheibel 2011-10-11 11:50:30 UTC
btw, thanks for the prompt support