0

Hy,

From time to time, not in a specific moment, my application crushes with this message.

Mprotect failed at 0x4f2f000 (length 12288) with errno 12
Stacktrace:

at Mono.Data.Sqlite.SqliteConvert.UTF8ToString (intptr,int) <0x000af>
at Mono.Data.Sqlite.SQLite3.GetText (Mono.Data.Sqlite.SqliteStatement,int) <0x00037>
at Mono.Data.Sqlite.SQLite3.GetValue (Mono.Data.Sqlite.SqliteStatement,int,Mono.Data.Sqlite.SQLiteType) <0x0047b>
at Mono.Data.Sqlite.SqliteDataReader.GetValue (int) <0x0009f>
at Mono.Data.Sqlite.SqliteDataReader.GetValues (object[]) <0x00057>
at TestLibertatea2.LocalDb.Query (string,Mono.Data.Sqlite.SqliteParameter[]) [0x0008c] in /Users/admin/Projects/TestLibertatea2/TestLibertatea2/Backend/Database/LocalDb.cs:68
at TestLibertatea2.LocalDb.QueryAsList (string,string,Mono.Data.Sqlite.SqliteParameter[]) [0x00006] in /Users/admin/Projects/TestLibertatea2/TestLibertatea2/Backend/Database/LocalDb.cs:85
at TestLibertatea2.LocalDb.QueryAsList (string,string) [0x00000] in /Users/admin/Projects/TestLibertatea2/TestLibertatea2/Backend/Database/LocalDb.cs:79
at TestLibertatea2.DbArticol.GetDbList (string) [0x00006] in /Users/admin/Projects/TestLibertatea2/TestLibertatea2/Backend/DbArticol.cs:37
at TestLibertatea2.HomePage.loadData () [0x00048] in /Users/admin/Projects/TestLibertatea2/TestLibertatea2/Controllers/HomePage.cs:105
at TestLibertatea2.HomePage.<ViewDidAppear>m__5 () [0x00000] in /Users/admin/Projects/TestLibertatea2/TestLibertatea2/Controllers/HomePage.cs:76
at MonoTouch.Foundation.NSActionDispatcher.Apply () <0x0002b>
at (wrapper runtime-invoke) object.runtime_invoke_dynamic (intptr,intptr,intptr,intptr) <0xffffffff>
at MonoTouch.UIKit.UIApplication.Main (string[],string,string) <0x000cf>
at MonoTouch.UIKit.UIApplication.Main (string[]) <0x00023>
at TestLibertatea2.Application.Main (string[]) [0x00000] in /Users/admin/Projects/TestLibertatea2/TestLibertatea2/Main.cs:17
at (wrapper runtime-invoke) object.runtime_invoke_dynamic (intptr,intptr,intptr,intptr) <0xffffffff>

Native stacktrace:

0   TestLibertatea2                     0x005bc51c mono_handle_native_sigsegv + 412
1   TestLibertatea2                     0x005e3708 sigabrt_signal_handler + 148
2   libsystem_c.dylib                   0x36aeb72f _sigtramp + 42
3   libsystem_c.dylib                   0x36ae03bb pthread_kill + 58
4   libsystem_c.dylib                   0x36ad8bff abort + 78
5   TestLibertatea2                     0x0070f044 GC_remap + 200
6   TestLibertatea2                     0x00702a28 GC_allochblk_nth + 1536
7   TestLibertatea2                     0x007023d8 GC_allochblk + 96
8   TestLibertatea2                     0x00708d0c GC_alloc_large + 92
9   TestLibertatea2                     0x007093b0 GC_generic_malloc + 324
10  TestLibertatea2                     0x00709690 GC_malloc_atomic + 332
11  TestLibertatea2                     0x00695ab0 mono_object_allocate_ptrfree + 64
12  TestLibertatea2                     0x00695c1c mono_array_new_specific + 148
13  TestLibertatea2                     0x0050f34c wrapper_managed_to_native_object___icall_wrapper_mono_array_new_specific_intptr_int + 68
14  TestLibertatea2                     0x00349e30 Mono_Data_Sqlite_SQLite3_GetText_Mono_Data_Sqlite_SqliteStatement_int + 56
15  TestLibertatea2                     0x0034ac10 Mono_Data_Sqlite_SQLite3_GetValue_Mono_Data_Sqlite_SqliteStatement_int_Mono_Data_Sqlite_SQLiteType + 1148
16  TestLibertatea2                     0x00361f90 Mono_Data_Sqlite_SqliteDataReader_GetValue_int + 160
17  TestLibertatea2                     0x00361ff4 Mono_Data_Sqlite_SqliteDataReader_GetValues_object__ + 88
18  TestLibertatea2                     0x001a01e8 TestLibertatea2_LocalDb_Query_string_Mono_Data_Sqlite_SqliteParameter__ + 1288
19  TestLibertatea2                     0x001a0704 TestLibertatea2_LocalDb_QueryAsList_string_string_Mono_Data_Sqlite_SqliteParameter__ + 256
20  TestLibertatea2                     0x001a05b8 TestLibertatea2_LocalDb_QueryAsList_string_string + 200
21  TestLibertatea2                     0x001bca90 TestLibertatea2_DbArticol_GetDbList_string + 304
22  TestLibertatea2                     0x0018b494 TestLibertatea2_HomePage_loadData + 516
23  TestLibertatea2                     0x0018cdc8 TestLibertatea2_HomePage__ViewDidAppearm__5 + 128
24  TestLibertatea2                     0x0005f3bc MonoTouch_Foundation_NSActionDispatcher_Apply + 44
25  TestLibertatea2                     0x0050a498 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 200
26  TestLibertatea2                     0x005a2064 mono_jit_runtime_invoke + 2800
27  TestLibertatea2                     0x00690d38 mono_runtime_invoke + 140
28  TestLibertatea2                     0x00716928 monotouch_trampoline + 2840
29  Foundation                          0x35dca7cd __NSFireTimer + 136
30  CoreFoundation                      0x33538a47 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 14
31  CoreFoundation                      0x3353aecb __CFRunLoopDoTimer + 850
32  CoreFoundation                      0x3353b845 __CFRunLoopRun + 1088
33  CoreFoundation                      0x334cbec3 CFRunLoopRunSpecific + 230
34  CoreFoundation                      0x334cbdcb CFRunLoopRunInMode + 58
35  GraphicsServices                    0x3639641f GSEventRunModal + 114
36  GraphicsServices                    0x363964cb GSEventRun + 62
37  UIKit                               0x330e8d69 -[UIApplication _run] + 404
38  UIKit                               0x330e6807 UIApplicationMain + 670
39  TestLibertatea2                     0x0008c6fc wrapper_managed_to_native_MonoTouch_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr + 240
40  TestLibertatea2                     0x0006af20 MonoTouch_UIKit_UIApplication_Main_string__ + 36
41  TestLibertatea2                     0x001847c8 TestLibertatea2_Application_Main_string__ + 128
42  TestLibertatea2                     0x0050a498 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 200
43  TestLibertatea2                     0x005a2064 mono_jit_runtime_invoke + 2800
44  TestLibertatea2                     0x00690d38 mono_runtime_invoke + 140
45  TestLibertatea2                     0x00693ce8 mono_runtime_exec_main + 784
46  TestLibertatea2                     0x00692d4c mono_runtime_run_main + 1048
47  TestLibertatea2                     0x005a9814 mono_jit_exec + 216
48  TestLibertatea2                     0x0059c620 main + 3616
49  TestLibertatea2                     0x000024a0 start + 52

Debug info from gdb:

Daniel
  • 789
  • 2
  • 9
  • 23

2 Answers2

0

You are running out of memory.

 mmap errno 12 Cannot Allocate Memory

Have a look at Explanation of MProtect Errno 12 (ENOMEM) and iPhone application crashes with Mprotect failed error (MonoTouch) to see some potential workaround (like using IDisposable whenever possible).

Community
  • 1
  • 1
poupou
  • 43,413
  • 6
  • 77
  • 174
  • And how do I test my memory? I use a timer in my navcontroller NSTimer.CreateRepeatingScheduledTimer( new TimeSpan(0,0,1), delegate { Console.WriteLine( String.Format( "Mem: {0:0,0}", GC.GetTotalMemory(false) ) ); }); And everything looks ok, memory doesn't grow unusual and it's getting disposed. – Daniel Aug 17 '11 at 20:27
  • "A number that is the best available approximation of the number of bytes currently allocated in managed memory.". Keywords are "approximation" and "managed" (the last call on the stack, with an IntPtr, is likely representing unmanaged memory). Ref: http://msdn.microsoft.com/en-us/library/system.gc.gettotalmemory.aspx Did you try overriding ReceiveMemoryWarning (like suggested in the second link) ? – poupou Aug 17 '11 at 22:28
  • Yes, I've override the ReceiveMemoryWarning and it's never called... It's something strange - on the simulator, the memory is not growing when I change the current UIViewController, but on the actual ipad device, memory is growing, and in one of this view changes the crash appears. – Daniel Aug 17 '11 at 23:12
  • I forgot to mention that I use Mono.Data.Sqlite, not the sqlite-net library on an iPad if it make's any difference... – Daniel Aug 17 '11 at 23:38
0

Ok, in the last version of monotouch ( 4.0.5 ) this problem is solved. My luck was that it was released just in time!

Daniel
  • 789
  • 2
  • 9
  • 23