Custom SQLite build from XCode doesn't work in Mono Develop - ios

I'm working on a iOS project that needs FTS on a SQLite DB.
I've followed the instructions found on the web concerning the building of a custom version of SQLite, together with a user function to order the results of a FTS by relevance, and built it all with XCode, setting a new Static library target and obtaining a libSQLite.a as output.
On iOS everything works ok! The FTS, the relevance order, etc.
Now there is the need to port everything on MonoTouch.
I've followed the instructions to use the libSQLite.a built from XCode in the MonoDevelop project, found at How to use FTS in SQLite with Monotouch for iOS
In particular, I wrote a SQLite wrapper in C# for the library thanks to the tutorial found at http://www.switchonthecode.com/tutorials/csharp-tutorial-writing-a-dotnet-wrapper-for-sqlite
I also changed the references to the .dll with __Internal as the SO Question said, but still I can't understand why it doesn't work.
The application starts and immediately crashes, even if I don't call any method of the SQLite class.
The code just stops at window.MakeKeyAndVisible();
This is the error:
Stacktrace:
at (wrapper managed-to-native) System.Reflection.Assembly.GetTypes (System.Reflection.Assembly,bool)
at System.Reflection.Assembly.GetTypes () [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/Assembly.cs:348
at MonoTouch.ObjCRuntime.Runtime.RegisterAssembly (System.Reflection.Assembly) [0x0004b] in /Users/plasma/Source/iphone/monotouch/ObjCRuntime/Runtime.cs:82
at (wrapper runtime-invoke) .runtime_invoke_void_object (object,intptr,intptr,intptr)
Native stacktrace:
0 SQLiteFTSTest 0x000d1965 mono_handle_native_sigsegv + 343
1 SQLiteFTSTest 0x0000ffb4 mono_sigsegv_signal_handler + 322
2 libSystem.B.dylib 0x980e845b _sigtramp + 43
3 ??? 0xffffffff 0x0 + 4294967295
4 ??? 0x077586fe 0x0 + 125142782
5 ??? 0x077586c1 0x0 + 125142721Error connecting stdout and stderr (127.0.0.1:10001)
6 ??? 0x0774df29 0x0 + 125099817
7 ??? 0x0774e055 0x0 + 125100117
8 SQLiteFTSTest 0x0000fd6f mono_jit_runtime_invoke + 1332
9 SQLiteFTSTest 0x001ee239 mono_runtime_invoke + 137
10 SQLiteFTSTest 0x0029bc55 monotouch_register + 90
11 SQLiteFTSTest 0x002a24d7 main + 3562
12 SQLiteFTSTest 0x000030c9 _start + 208
13 SQLiteFTSTest 0x00002ff8 start + 40
14 ??? 0x00000002 0x0 + 2
Debug info from gdb:
/tmp/mono-gdb-commands.A3ljfK:1: Error in sourced command file:
unable to debug self
What should I do?

Related

iOS React Native app runs perfectly in testing but crashes in release build

I wrote a simple app with React Native targeting iOS. When I build the app in Xcode to test on simulators or my iPhone everything works perfectly. When I archive the build in Xcode and load it on my iPhone using the development option, it crashes when I press the only button on screen on start.
The app source code can be found on GitHub.
I am using React Native ~0.63.4 and React: 16.13.1 in a bare Expo workflow.
Third party dependencies:
#react-native-async-storage/async-storage
expo-constants
expo-notifications
uuid
react-native-date-picker
Here is a full crash report from the device logs: Google Drive
I'm at a loss trying to interpret the crash logs but the thread that crashes is exactly this everytime (except for the thread number):
Thread 3 name: Dispatch queue: com.facebook.react.ExceptionsManagerQueue
Thread 3 Crashed:
0 libsystem_kernel.dylib 0x00000001d285f414 __pthread_kill + 8
1 libsystem_pthread.dylib 0x00000001eed77b40 pthread_kill + 272
2 libsystem_c.dylib 0x00000001aec84b74 abort + 104
3 libc++abi.dylib 0x00000001b9fbccf8 __cxxabiv1::__aligned_malloc_with_fallback+ 81144 (unsigned long) + 0
4 libc++abi.dylib 0x00000001b9fade4c demangling_unexpected_handler+ 20044 () + 0
5 libobjc.A.dylib 0x00000001b9eb6f64 _objc_terminate+ 28516 () + 144
6 libc++abi.dylib 0x00000001b9fbc0e0 std::__terminate(void (*)+ 78048 ()) + 20
7 libc++abi.dylib 0x00000001b9fbc06c std::terminate+ 77932 () + 44
8 libdispatch.dylib 0x00000001a5554dc4 _dispatch_client_callout + 40
9 libdispatch.dylib 0x00000001a555c10c _dispatch_lane_serial_drain + 580
10 libdispatch.dylib 0x00000001a555cc5c _dispatch_lane_invoke + 408
11 libdispatch.dylib 0x00000001a5566d78 _dispatch_workloop_worker_thread + 708
12 libsystem_pthread.dylib 0x00000001eed78804 _pthread_wqthread + 276
13 libsystem_pthread.dylib 0x00000001eed7f75c start_wqthread + 8
When I open the app while connected to my laptop and have the console for my iPhone open while crashing the app, I first get these messages under Errors and Faults:
error 16:14:06.383233-0500 remindrs Error: Requiring unknown module "undefined".
error 16:14:06.386759-0500 remindrs Unhandled JS Exception: Error: Requiring unknown module "undefined".
error 16:14:06.463315-0500 SpringBoard Ignoring state for untracked process [application<org.name.remindrs>:5966]: <RBSProcessState| task:none debug:none>
fault 16:14:06.559231-0500 SpringBoard Unable to move topic <private>, This topic was not in the list provided! APSTopicListOpportunistic
I've tried cleaning the build folder, turning off Swift compiler optimizations, and rearchived the project multiple times.
None of my searching has paid off and I'm not sure how to identify the issue I am having. I don't know if it is with React Native or with some configuration in Xcode.
Thank you for your help!
I solved the problem by removing a few lines of codes dealing with a Date. I'm not sure why this caused a crash in release and not debug but the problem is fixed!

Realm debug symbols missing?

I'm working on an iOS app that uses Realm which is installed/managed via Cocoapods. My app crashes sporadically and I'm having difficulty troubleshooting the problem because my stack trace doesn't show me the method names related to Realm. I am deploying a debug build of my app to the phone via Xcode and I have the Debug Information Format option set to DWARF with dSYM File. In the stack trace below you can see that my code appears to be symbolicated but the method names in Realm are just addresses and offsets. Unfortunately, I'm somewhat new to troubleshooting with Xcode but I'm under the assumption that this means the Realm debug symbols could not be found? If anyone can explain to me how to correct this, I'd really appreciate it!
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Triggered by Thread: 0
Application Specific Information:
abort() called
Filtered syslog:
None found
Last Exception Backtrace:
0 CoreFoundation 0x18316ad8c __exceptionPreprocess + 228
1 libobjc.A.dylib 0x1823245ec objc_exception_throw + 55
2 Realm 0x10814e238 0x108030000 + 1172024
3 Realm 0x10814ffa0 0x108030000 + 1179552
4 Realm 0x10814ff74 0x108030000 + 1179508
5 MyAppName 0x104af31a4 closure #1 in closure #2 in processOutgoingMessage(outgoingMessage:) + 4452772 (ProcessOutgoingMessage.swift:51)
6 MyAppName 0x1046cd168 _T0Ieg_IeyB_TR + 102760 (DataSource.swift:0)
7 libdispatch.dylib 0x182a5caa0 _dispatch_call_block_and_release + 23
8 libdispatch.dylib 0x182a5ca60 _dispatch_client_callout + 15
9 libdispatch.dylib 0x182a9dd80 _dispatch_main_queue_callback_4CF$VARIANT$armv81 + 963
10 CoreFoundation 0x183113070 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 11
11 CoreFoundation 0x183110bc8 __CFRunLoopRun + 2271
12 CoreFoundation 0x183030da8 CFRunLoopRunSpecific + 551
13 GraphicsServices 0x185015020 GSEventRunModal + 99
14 UIKit 0x18d04d758 UIApplicationMain + 235
15 MyAppName 0x104a7919c main + 3953052 (AppDelegate.swift:18)
16 libdyld.dylib 0x182ac1fc0 start + 3
UPDATE - as it turns out, the Build Settings for the Pods project (recall that I'm using Realm via Cocoapods) needed to also have the Debug Information Format set to DWARF with dSYM File for debug builds. My app hasn't crashed again yet but I did notice that when I cleaned and rebuilt the app this time it appeared to be including the debug symbols for Realm so here's hoping.

Figuring out an iOS Simulator crash report

I am writing an App using the Appcelerator framework, and I get occasional crashes. I'm trying to track down whats causing the crash, so I decided to take a look at the iOS simulator crash report. Its of course all greek to me, but was hoping for some guidance on what part of this is a clue to the cause of the crash?
I pulled out the thread which is labeled as 'Crashed', but within that thread there are multiple entries (0-9), listed below. Is there any clue to figuring out which of those entries is causing the problem?
Crashed Thread: 2 KrollContext<kroll$1>
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00000000bbadbeef
Thread 2 Crashed:: KrollContext<kroll$1>
0 com.a 0x000000010082865e Ti_WTFCrash + 62
1 com.a 0x000000010069ffe9 TiObjectGetProperty + 361
2 com.a 0x00000001002c42e5 -[KrollObject objectForTiString:context:] + 101
3 com.a 0x00000001002bf6a5 KrollGetProperty + 165
4 com.a 0x0000000100656ef7 TI::JSCallbackObject<TI::JSDestructibleObject>::getOwnPropertySlot(TI::JSObject*, TI::ExecState*, TI::PropertyName, TI::PropertySlot&) + 487
5 com.a 0x00000001005e32aa TI::TiValue::get(TI::ExecState*, TI::PropertyName, TI::PropertySlot&) const + 362
6 com.a 0x00000001006f6ec0 llint_slow_path_get_by_id + 192
7 com.a 0x0000000100701711 llint_op_get_by_id + 98
8 com.a 0x0000000100703ae2 llint_op_call + 153
9 com.a 0x00000001006ffea5 callToJavaScript + 191
SIGSEGV errors occur when you try to use an object that already has been garbage collected. It's the equivalent of NullPointer errors on Android.
Seeing it has callToJavaScript as well would mean a native event or callback is not finding the JavaScript object anymore.
I'd advise to use the Appcelerator Studio debugger and step through the code to the moment it crashes.

Segfault on loading a dylib with a constructor - only in Release builds

I'm writing a dynamic library in Objective-C, and recently I started experiencing a very strange issue, where loading the dylib triggers a segfault crash as soon as it's loaded. The trouble is, this only occurs in Release builds - Debug builds work just fine. Here's an example of the relevant stack trace in the crash:
Terminating due to signal Segmentation fault: 11; backtrace: (
0 <redacted>.dylib 0x003417a9 SignalHandler + 52
1 libsystem_c.dylib 0x39cded33 _sigtramp + 34
2 CoreFoundation 0x31abaac9 CFRelease + 1104
3 ??? 0x2ff07629 0x0 + 804288041
4 ??? 0x2ff04a39 0x0 + 804276793
5 ??? 0x2ff04875 0x0 + 804276341
6 ??? 0x2fefdfff 0x0 + 804249599
7 ??? 0x2ff01a47 0x0 + 804264519
8 libdyld.dylib 0x39c97949 dlopen + 48
9 CoreFoundation 0x31b31b11 <redacted> + 116
10 CoreFoundation 0x31b067cb _CFBundleLoadExecutableAndReturnError + 418
11 Foundation 0x32424159 <redacted> + 848
I experimented with the code a bit and narrowed down the source of the crash to a single constructor in my code. When this constructor is removed, the crash no longer occurs. But if I do so much as include a printf statement in the constructor, the crash reappears. Something as simple as this triggers it:
static void __attribute__((constructor)) TestConstructor() {
printf("THIS IS A TEST");
}
I should also mention that I do have other constructor functions in other files (all declared statically), and each of those works fine. It's this particular constructor that is causing the crash, and that's what really confuses me.
Any ideas? I'm not sure how to debug it further from here.

how to disable "profile" in monodevelop

In monodevelop try menu > project > profile mono..., before try it, every works fine , but now is imposible for me debug in iphone debug simulator. always same error
In release simulator work fine
In iphone real device work fine
In debug simulator the error:
I think disabled profile mono..., but is not posible, i dont know reason, Thanks.
Native stacktrace:
0 myprogram 0x0009524c mono_handle_native_sigsegv + 284
1 myprogram 0x0000bb38 mono_sigsegv_signal_handler + 248
2 libsystem_c.dylib 0x9ae6059b _sigtramp + 43
3 ??? 0xffffffff 0x0 + 4294967295
4 myprogram 0x001a4a62 single_arg_user_copy_or_mark + 34
5 myprogram 0x001ce400 mark_tls_slots + 128
6 myprogram 0x001a81b0 scan_from_registered_roots + 336
7 myprogram 0x001b4356 major_collection + 2886
8 myprogram 0x001b5098 mono_gc_collect + 88
9 myprogram 0x002233a6 monotouch_pump_gc + 38
10 libsystem_c.dylib 0x9ae08ed9 _pthread_start + 335
11 libsystem_c.dylib 0x9ae0c6de thread_start + 34
=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
In order to use MonoDevelop's profiler you had to enable the SGEN garbage collector (GC). This is (from the stack trace) what's causing your crash.
You need to go back to your project's options (MonoTouch Build) and, under the Advanced tab, unselect the "Use SGEN generational garbage collector".
Once you have changed this, re-build your solution and it should work fine (the reason it works for release build is because the GC settings, like most of them, are kept separate between Debug and Release builds).
Now there's likely something broken because it should not be crashing like this. Would it be possible for you to report this issue (with a test case) to http://bugzilla.xamarin.com so our GC developers can get a look at what caused this issue ? Thanks!

Resources