Bug 6680 - Sqlite3 causing crashes
Summary: Sqlite3 causing crashes
Status: RESOLVED INVALID
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 5.2
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-08-24 10:25 UTC by René Ruppert
Modified: 2012-08-30 14:34 UTC (History)
3 users (show)

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

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 René Ruppert 2012-08-24 10:25:11 UTC
MT 5.2.13

I cannot put my finger on it, but I keep seeing malloc issues in Sqlite3. I know, you want a reproducible case, but I cannot provide it. But whenerver I get "malloc failed" or something like that, it is coming from Sqlite.

Latest one:


BrainloopBrowser(5786,0xac3cfa28) malloc: *** error for object 0x4: Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Stacktrace:

  at (wrapper managed-to-native) Mono.Data.Sqlite.UnsafeNativeMethods.sqlite3_prepare (intptr,intptr,int,intptr&,intptr&) <IL 0x0002a, 0xffffffff>
  at Mono.Data.Sqlite.SQLite3.Prepare (Mono.Data.Sqlite.SqliteConnection,string,Mono.Data.Sqlite.SqliteStatement,uint,string&) [0x00044] in /Developer/MonoTouch/Source/mono/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLite3.cs:268
  at Mono.Data.Sqlite.SqliteCommand.BuildNextCommand () [0x00019] in /Developer/MonoTouch/Source/mono/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLiteCommand.cs:230
  at Mono.Data.Sqlite.SqliteCommand.GetStatement (int) [0x0000b] in /Developer/MonoTouch/Source/mono/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLiteCommand.cs:264
  at (wrapper remoting-invoke-with-check) Mono.Data.Sqlite.SqliteCommand.GetStatement (int) <IL 0x00039, 0xffffffff>
  at Mono.Data.Sqlite.SqliteDataReader.NextResult () [0x000cc] in /Developer/MonoTouch/Source/mono/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLiteDataReader.cs:897
  at Mono.Data.Sqlite.SqliteDataReader..ctor (Mono.Data.Sqlite.SqliteCommand,System.Data.CommandBehavior) [0x00051] in /Developer/MonoTouch/Source/mono/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLiteDataReader.cs:89
BrainloopBrowser(5786,0xac3cfa28) malloc: *** error for object 0x2: Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
  at (wrapper remoting-invoke-with-check) Mono.Data.Sqlite.SqliteDataReader..ctor (Mono.Data.Sqlite.SqliteCommand,System.Data.CommandBehavior) <IL 0x00021, 0xffffffff>
  at Mono.Data.Sqlite.SqliteCommand.ExecuteReader (System.Data.CommandBehavior) [0x00006] in /Developer/MonoTouch/Source/mono/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLiteCommand.cs:539
  at Mono.Data.Sqlite.SqliteCommand.ExecuteReader () [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLiteCommand.cs:551
  at (wrapper remoting-invoke-with-check) Mono.Data.Sqlite.SqliteCommand.ExecuteReader () <IL 0x00038, 0xffffffff>
  at BrainloopMobile.Items.LocalServer.GetServer (int) [0x00024] in /Users/rene/Documents/Develop/Projects/BrainloopMobile/220/BrainloopMobile/BrainloopMobile/Items/LocalServer.cs:202
  at BrainloopMobile.Items.LocalServer.GetAPIManager (BrainloopMobile.ServerUniqueDataroomID) [0x00043] in /Users/rene/Documents/Develop/Projects/BrainloopMobile/220/BrainloopMobile/BrainloopMobile/Items/LocalServer.cs:468
  at BrainloopMobile.ProgressPreviewItem.ProgressLoop (BrainloopMobile.Progress.IProgressContext) [0x00000] in /Users/rene/Documents/Develop/Projects/BrainloopMobile/220/BrainloopMobile/BrainloopMobile/Progress/ProgressPreviewItem.cs:160
  at BrainloopMobile.Progress.ModalProgressController.StartProgress () [0x00014] in /Users/rene/Documents/Develop/Projects/BrainloopMobile/220/BrainloopMobile/BrainloopMobile/Progress/Base/ModalProgressController.cs:304
  at System.Threading.Thread.StartInternal () [0x0001d] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Threading/Thread.cs:696
  at (wrapper runtime-invoke) object.runtime_invoke_void__this__ (object,intptr,intptr,intptr) <IL 0x0004e, 0xffffffff>

Native stacktrace:

	0   BrainloopBrowser                    0x00094cac mono_handle_native_sigsegv + 284
	1   BrainloopBrowser                    0x0000bb98 mono_sigsegv_signal_handler + 248
	2   libsystem_c.dylib                   0x91adf86b _sigtramp + 43
	3   ???                                 0xffffffff 0x0 + 4294967295
	4   libsqlite3.dylib                    0x04875a0d sqlite3WalkSelect + 77
	5   libsqlite3.dylib                    0x0487e4ac sqlite3SelectPrep + 76
	6   libsqlite3.dylib                    0x048b730a sqlite3Select + 410
	7   libsqlite3.dylib                    0x048f563c yy_reduce + 7900
	8   libsqlite3.dylib                    0x048ffb04 sqlite3Parser + 244
	9   libsqlite3.dylib                    0x048ffdd1 sqlite3RunParser + 577
	10  libsqlite3.dylib                    0x04900bcb sqlite3Prepare + 683
	11  libsqlite3.dylib                    0x049011bb sqlite3LockAndPrepare + 299
	12  libsqlite3.dylib                    0x048e5785 sqlite3_prepare + 53
	13  ???                                 0x12e2d227 0x0 + 316854823
	14  ???                                 0x12e2c508 0x0 + 316851464
	15  ???                                 0x12e2c001 0x0 + 316850177
	16  ???                                 0x12e2bd14 0x0 + 316849428
	17  ???                                 0x12e2bc94 0x0 + 316849300
	18  ???                                 0x12e2b654 0x0 + 316847700
	19  ???                                 0x12e2b1a2 0x0 + 316846498
	20  ???                                 0x12e2b018 0x0 + 316846104
	21  ???                                 0x12e2a404 0x0 + 316843012
	22  ???                                 0x12e31d30 0x0 + 316874032
	23  ???                                 0x12e31ccc 0x0 + 316873932
	24  ???                                 0x13ed85ac 0x0 + 334333356
	25  ???                                 0x14320124 0x0 + 338821412
	26  ???                                 0x1431e85c 0x0 + 338815068
	27  ???                                 0x1430ebf8 0x0 + 338750456
	28  ???                                 0x14302516 0x0 + 338699542
	29  ???                                 0x099f0a50 0x0 + 161417808
	30  BrainloopBrowser                    0x0000ff02 mono_jit_runtime_invoke + 722
	31  BrainloopBrowser                    0x00171e8e mono_runtime_invoke + 126
	32  BrainloopBrowser                    0x00171ffc mono_runtime_delegate_invoke + 140
	33  BrainloopBrowser                    0x001d1ce2 start_wrapper + 482
	34  BrainloopBrowser                    0x00203bea thread_start_routine + 154
	35  BrainloopBrowser                    0x001ae9d0 gc_start_thread + 80
	36  libsystem_c.dylib                   0x91af3557 _pthread_start + 344
	37  libsystem_c.dylib                   0x91addcee thread_start + 34
Comment 1 Sebastien Pouliot 2012-08-24 11:13:49 UTC
No much we can't do without being able to duplicate the issue. This occurs deep inside the native library (shipped with iOS). A few things might prove useful:

* Since it's an iOS library please include the iOS version(s) when submitting crash. We might find a pattern with this information (if we get other similar reports);

* Please state if crashes occurs on the simulator, devices or both. If you get this on device then attach the crash report (you can mark it private) not just the stack trace. Other threads might be doing "weird" things and we can't know without a more complete dump;

* Also (if on device) look the the console logs (from Xcode) and paste/attach the last page (or so) form it. If iOS complained about something else (in or out-of-process) then it might provide useful (e.g. to duplicate the issue);

* Look at future crashes. If the stack trace is different then please add it to the bug report (again with the iOS version used);

* Like I said on stackoverflow [1] it's possible that another native library is causing issues (e.g. corrupting memory) but since libsqlite is (likely) used more often it's the one that gets to crash. Try a divide-and-conquer strategy to see if excluding other native libraries "fix" this crash;

[1] http://stackoverflow.com/q/12111336/220643
Comment 2 René Ruppert 2012-08-30 14:34:09 UTC
Turned out that using SqliteConnection.SetConfig( SQLiteConfig.Serialized); fixes the issue.