help understanding MonoTouch crash log - xamarin.ios

My MonoTouch app (release build) is crashing randomly and I'm getting this in the crash log. Unfortunately, I don't see anything useful related to my app. It looks like it's down deep in the bowels of MonoTouch and iOS.
I'm running this on an iPhone 3G with OS 3.1.2.
Can anyone help me understand what this crash log means?
Incident Identifier: 222781AB-0F7C-4E1D-9E10-6EE946D6C320
CrashReporter Key: 0ee985a48f32f63b7e50536870f06a1ab4122600
Process: MyApp_iOS [593]
Path: /var/mobile/Applications/095A615B-2F9B-4A84-B0E3-EF1246915594/MyApp_iOS.app/MyApp_iOS
Identifier: MyApp_iOS
Version: ??? (???)
Code Type: ARM (Native)
Parent Process: launchd [1]
Date/Time: 2011-03-24 13:04:18.479 -0700
OS Version: iPhone OS 3.1.2 (7D11)
Report Version: 104
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x00000000, 0x00000000
Crashed Thread: 0
Thread 0 Crashed:
0 dyld 0x2fe125b2 ImageLoaderMachOCompressed::findExportedSymbol(char const*, ImageLoader const**) const + 58
1 dyld 0x2fe0dcd6 ImageLoaderMachO::findExportedSymbol(char const*, bool, ImageLoader const**) const + 30
2 dyld 0x2fe0ee6e ImageLoaderMachOClassic::resolveUndefined(ImageLoader::LinkContext const&, macho_nlist const*, bool, bool, ImageLoader const**) + 434
3 dyld 0x2fe10250 ImageLoaderMachOClassic::doBindLazySymbol(unsigned long*, ImageLoader::LinkContext const&) + 212
4 dyld 0x2fe037ae dyld::bindLazySymbol(mach_header const*, unsigned long*) + 94
5 dyld 0x2fe0e29c stub_binding_helper_interface + 12
6 MyApp_iOS 0x0071a754 mono_handle_native_sigsegv (mini-exceptions.c:1762)
7 MyApp_iOS 0x0073d900 sigabrt_signal_handler (mini-posix.c:155)
8 libSystem.B.dylib 0x0008e81c _sigtramp + 28
9 libSystem.B.dylib 0x00033904 semaphore_wait_signal + 4
10 libSystem.B.dylib 0x00003ca8 pthread_mutex_lock + 440
11 MyApp_iOS 0x0088e76c GC_lock (pthread_support.c:1679)
12 MyApp_iOS 0x00884970 GC_malloc_atomic (malloc.c:259)
13 MyApp_iOS 0x007f26e4 mono_object_new_ptrfree_box (object.c:3996)
[... there are 10 active threads but I've only included the one that crashed]
Thread 0 crashed with ARM Thread State:
r0: 0x00000000 r1: 0x0097dc97 r2: 0x344d7c3c r3: 0x344dd2bd
r4: 0x344dd2bd r5: 0x00005681 r6: 0x0097dc97 r7: 0x2fffe6d8
r8: 0x344e7f34 r9: 0x00000001 r10: 0x0000007f r11: 0x0097dc97
ip: 0x344d8e4c sp: 0x2fffe658 lr: 0x2fe0dcdd pc: 0x2fe125b2
cpsr: 0x20000030

Another diagnosis option I've found is to:
Hook up AppDomain.CurrentDomain.UnhandledException
Put a try-catch around your entire "static void Main()" method
In both causes write the exception to Console.WriteLine().
Then run your app, open XCode and open the console window for your device while it's plugged in. Then cause the crash. You should be able to see a decent C# stack trace of the exception.
This has helped me fix many issues that only happen when running in release on the device.

Related

Writing string to file in Swift 3 for Ubuntu Linux

I am currently porting my framework to server-side Swift and I stumbled upon a crash when writing a string to a file. Under macOS it is working.
The source code
#!/usr/bin/swift
import Foundation
let url = URL(string: "/tmp/foo")!
let line = "foobar"
print("writing to \(url)")
try line.write(to: url, atomically: true, encoding: String.Encoding.utf8)
causes that Segmentation Fault:
root#bd5d9b821031:/# ./test.swift
writing to <CFURL 0x67b66e0 [0x7ff283886840]>{string = /tmp/foo, encoding = 0, base = (null)}
0 swift 0x000000000333cb08 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1 swift 0x000000000333b2d6 llvm::sys::RunSignalHandlers() + 54
2 swift 0x000000000333d63a
3 libpthread.so.0 0x00007ff28921b330
4 libswiftCore.so 0x00007ff285c3f648 swift_getErrorValue + 8
5 libswiftCore.so 0x00007ff2896462d1 swift_getErrorValue + 60845201
6 swift 0x0000000000c161f4 llvm::MCJIT::runFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>) + 996
7 swift 0x0000000000c197af llvm::ExecutionEngine::runFunctionAsMain(llvm::Function*, std::vector<std::string, std::allocator<std::string> > const&, char const* const*) + 1215
8 swift 0x00000000007e6bff swift::RunImmediately(swift::CompilerInstance&, std::vector<std::string, std::allocator<std::string> > const&, swift::IRGenOptions&, swift::SILOptions const&) + 2367
9 swift 0x00000000007e0818
10 swift 0x00000000007dbab7 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2887
11 swift 0x00000000007a7568 main + 2872
12 libc.so.6 0x00007ff2879c4f45 __libc_start_main + 245
13 swift 0x00000000007a4f66
Stack dump:
0. Program arguments: /usr/bin/swift -frontend -interpret ./test.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -color-diagnostics -module-name test
Segmentation fault
I also tried to wrap it in a do ... catch but the segfault still occurs. Any ideas how to fix it are deeply appreciated!
I guess problem is in this line
let url = URL(string: "/tmp/foo")!
Try replacing it with
let url = URL(fileURLWithPath: "/tmp/foo")
This way you gonna get proper file url

xamarin - mono-rt: Stack overflow in unmanaged: IP: xxx, fault addr: yyy

My (xamarin.iOS) app always crashes after a while with the below error
Message:
mono-rt: Stack overflow in unmanaged: IP: 0x29c2cc, fault addr:
0xb0aedf4c
mono-rt: Stack overflow in unmanaged: IP: 0x29c2cc, fault addr:
0xb0aecdcc
The requested operation caused a stack overflow.
Stack Trace:
at (wrapper managed-to-native) object:__icall_wrapper_mono_array_new_specific (intptr,int)
at System.Threading.Tasks.Task.HandleGenericException (System.Exception e) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Threading.Tasks/Task.cs:640
at System.Threading.Tasks.Task.ThreadStart () [0x00123] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Threading.Tasks/Task.cs:445
at System.Threading.Tasks.Task.Execute () [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Threading.Tasks/Task.cs:514
at System.Threading.Tasks.TpScheduler.TaskExecuterCallback (System.Object obj) [0x00007] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Threading.Tasks/TpScheduler.cs:59
Native
mono-rt: 0 RTouchIpad 0x001492d7 mono_handle_native_sigsegv + 327
mono-rt: 1 RTouchIpad 0x00153bfa sigabrt_signal_handler + 122
mono-rt: 2 libsystem_platform.dylib 0x056fbdeb _sigtramp + 43
mono-rt: 3 ??? 0xffffffff 0x0 + 4294967295
mono-rt: 4 libsystem_sim_c.dylib 0x05414e12 abort + 127
mono-rt: 5 RTouchIpad 0x002b8f33 monotouch_unhandled_exception_handler + 291
mono-rt: 6 RTouchIpad 0x00149afb mono_invoke_unhandled_exception_hook + 91
mono-rt: 7 RTouchIpad 0x00148b2c mono_handle_exception_internal + 6620
mono-rt: 8 RTouchIpad 0x00147149 mono_handle_exception + 41
mono-rt: 9 RTouchIpad 0x000e30b9 mono_x86_throw_exception + 137
mono-rt: 10 ??? 0x0fbbde57 0x0 + 263970391
mono-rt: 11 RTouchIpad 0x00148eb9 mono_altstack_restore_prot + 9
mono-rt: 12 ??? 0x0fbbd83c 0x0 + 263968828
mono-rt: 13 ??? 0x148185b0 0x0 + 344032688
mono-rt: 14 ??? 0x13fcbcd0 0x0 + 335330512
mono-rt: 15 ??? 0x13fcb558 0x0 + 335328600
mono-rt: 16 ??? 0x13fcb4fc 0x0 + 335328508
mono-rt: 17 ??? 0x0ff64827 0x0 + 267798567
mono-rt: 18 RTouchIpad 0x001797db mono_jit_runtime_invoke + 843
mono-rt: 19 RTouchIpad 0x002102ff mono_runtime_invoke + 127
mono-rt: 20 RTouchIpad 0x002153ec mono_runtime_delegate_invoke + 92
mono-rt: 21 RTouchIpad 0x002450ee async_invoke_thread + 2446
mono-rt: 22 RTouchIpad 0x00250028 start_wrapper + 376
mono-rt: 23 RTouchIpad 0x00285aa0 inner_start_thread + 240
mono-rt: 24 RTouchIpad 0x0029ed5d GC_start_routine + 93
mono-rt: 25 libsystem_pthread.dylib 0x057ea5fb _pthread_body + 144
mono-rt: 26 libsystem_pthread.dylib 0x057ea485 _pthread_struct_init + 0
mono-rt: 27 libsystem_pthread.dylib 0x057efcf2 thread_start + 34
mono-rt:
=================================================================
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.
=================================================================
Any idea how to best solve this issue?
Such crashes are often caused by a memory corruption inside the application. This is not easy to diagnose unless there's a (symbolicated) crash report (which will include every threads).
You can try to run your application under Instruments and it might pinpoint something unusual.
You can also file a bug report and include a reproducible test case (or, at a minimum, the symbolicated crash report).

input element of type range leaks in UIWebView

I was about to submit my app for review when I discovered that the input element of type range in my UIWebView leaks 12 bytes when added to the document. There are no subsequent leaks; not even when the slider is used.
I would be grateful for any advice as to how to proceed with my submission. Should I be worried at all about 12 bytes? Should I find a way around this, say, by not using this element at all? Or, should I make a note of the leak to the reviewers (under Review Notes rubric)?
The leak can be replicated with a minimal UIWebView application:
#import "TjaViewController.h"
#interface TjaViewController ()
#property (weak, nonatomic) IBOutlet UIWebView *webView;
#end
#implementation TjaViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[self.webView loadHTMLString:#"<input type='range'>" baseURL:nil];
}
#end
Profiling the app with Instruments yields a single leak with the following properties:
Category: Malloc 12 Bytes
Retain Count: 1
Responsible Library: JavaScriptCore
Responsible Caller: WTF::fastMalloc(unsigned long)
Stack trance:
32 libsystem_pthread.dylib thread_start
31 libsystem_pthread.dylib _pthread_start
30 libsystem_pthread.dylib _pthread_body
29 WebCore RunWebThread(void*)
28 CoreFoundation CFRunLoopRunInMode
27 CoreFoundation CFRunLoopRunSpecific
26 CoreFoundation __CFRunLoopRun
25 CoreFoundation __CFRunLoopDoSources0
24 CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
23 WebCore HandleRunSource
22 WebCore ___ZN7WebCoreL26applicationDidBecomeActiveEP22__CFNotificationCenterPvPK10__CFStringPKvPK14__CFDictionary_block_invoke
21 WebCore WebCore::ThreadTimers::sharedTimerFiredInternal()
20 WebCore WebCore::DocumentLoader::handleSubstituteDataLoadNow(WebCore::Timer<WebCore::DocumentLoader>*)
19 WebCore WebCore::DocumentLoader::responseReceived(WebCore::CachedResource*, WebCore::ResourceResponse const&)
18 WebCore WebCore::DocumentLoader::continueAfterContentPolicy(WebCore::PolicyAction)
17 WebCore WebCore::DocumentLoader::dataReceived(WebCore::CachedResource*, char const*, int)
16 WebCore WebCore::DocumentLoader::commitLoad(char const*, int)
15 WebKit WebFrameLoaderClient::committedLoad(WebCore::DocumentLoader*, char const*, int)
14 WebKit -[WebDataSource(WebInternal) _receivedData:]
13 WebKit -[WebHTMLRepresentation receivedData:withDataSource:]
12 WebCore WebCore::DocumentLoader::commitData(char const*, unsigned long)
11 WebCore WebCore::DecodedDataDocumentParser::appendBytes(WebCore::DocumentWriter*, char const*, unsigned long)
10 WebCore WebCore::HTMLDocumentParser::append(WTF::PassRefPtr<WTF::StringImpl>)
9 WebCore WebCore::HTMLDocumentParser::pumpTokenizer(WebCore::HTMLDocumentParser::SynchronousMode)
8 WebCore WebCore::HTMLDocumentParser::constructTreeFromHTMLToken(WebCore::HTMLToken&)
7 WebCore WebCore::HTMLConstructionSite::executeQueuedTasks()
6 WebCore WebCore::executeTask(WebCore::HTMLConstructionSiteTask&)
5 WebCore WebCore::insert(WebCore::HTMLConstructionSiteTask&, bool)
4 WebCore WebCore::HTMLInputElement::attach(WebCore::Node::AttachContext const&)
3 WebCore WebCore::FeatureObserver::didObserve(WebCore::FeatureObserver::Feature)
2 JavaScriptCore WTF::BitVector::resizeOutOfLine(unsigned long)
1 JavaScriptCore WTF::fastMalloc(unsigned long)
0 JavaScriptCore WTF::MallocHook::recordAllocation(void*, unsigned long)
I think I figured it out
Seems it's a leak in libWTF
and here is the original code from https://github.com/leolannenmaki/JavaScriptCore-iOS
void BitVector::resizeOutOfLine(size_t numBits)
{
ASSERT(numBits > maxInlineBits());
OutOfLineBits* newOutOfLineBits = OutOfLineBits::create(numBits);
size_t newNumWords = newOutOfLineBits->numWords();
if (isInline()) {
// Make sure that all of the bits are zero in case we do a no-op resize.
*newOutOfLineBits->bits() = m_bitsOrPointer & ~(static_cast<uintptr_t>(1) << maxInlineBits());
memset(newOutOfLineBits->bits() + 1, 0, (newNumWords - 1) * sizeof(void*));
} else {
if (numBits > size()) {
size_t oldNumWords = outOfLineBits()->numWords();
memcpy(newOutOfLineBits->bits(), outOfLineBits()->bits(), oldNumWords * sizeof(void*));
memset(newOutOfLineBits->bits() + oldNumWords, 0, (newNumWords - oldNumWords) * sizeof(void*));
} else
memcpy(newOutOfLineBits->bits(), outOfLineBits()->bits(), newOutOfLineBits->numWords() * sizeof(void*));
OutOfLineBits::destroy(outOfLineBits());
}
m_bitsOrPointer = bitwise_cast<uintptr_t>(newOutOfLineBits) >> 1;
}
And it's obviously the newOutOfLineBits is not destroied when code goes isInline()
I tried to replace the system JavascriptCore.framework
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk/System/Library/Frameworks/JavaScriptCore.framework
but failed, the system framework is compiled from dynamic library
as far as I know, apple forbids compile dynamic library for iOS...
so I think the only way is to report this leak to Apple...

My Apps not working for iOS 4.2.1

I have uploaded my latest iPhone Application on iTunes, Its working fine for iOS 6.0 and iOS 5 but when i have download app on iOS 4.2.1 its downloaded successfully but its not being run. Its display black screen for a moment and after crashed. Please check crash log below.
Version: ??? (???)
Code Type: ARM (Native)
Parent Process: launchd [1]
Date/Time: 2012-10-25 10:20:20.830 +0100
OS Version: iPhone OS 4.3.5 (8L1)
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00000000
Crashed Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 MeteorElectrical 0x0002d12a 0x1000 + 180522
1 MeteorElectrical 0x0000268e 0x1000 + 5774
2 UIKit 0x3503281a 0x34ffd000 + 219162
3 UIKit 0x3502cb5e 0x34ffd000 + 195422
4 UIKit 0x350017d0 0x34ffd000 + 18384
5 UIKit 0x3500120e 0x34ffd000 + 16910
6 UIKit 0x35000c4c 0x34ffd000 + 15436
7 GraphicsServices 0x3593be70 0x35937000 + 20080
8 CoreFoundation 0x361eea90 0x36179000 + 481936
9 CoreFoundation 0x361f0838 0x36179000 + 489528
10 CoreFoundation 0x361f1606 0x36179000 + 493062
11 CoreFoundation 0x36181ebc 0x36179000 + 36540
12 CoreFoundation 0x36181dc4 0x36179000 + 36292
13 UIKit 0x3502bd42 0x34ffd000 + 191810
14 UIKit 0x35029800 0x34ffd000 + 182272
15 MeteorElectrical 0x0000214e 0x1000 + 4430
16 MeteorElectrical 0x000020e0 0x1000 + 4320
Thread 1:
0 libsystem_kernel.dylib 0x33ec03ec 0x33eae000 + 74732
1 libsystem_c.dylib 0x33efa6d8 0x33ec6000 + 214744
2 libsystem_c.dylib 0x33efabbc 0x33ec6000 + 215996
Thread 2 name: Dispatch queue: com.apple.libdispatch-manager
Thread 2:
0 libsystem_kernel.dylib 0x33ec0fbc 0x33eae000 + 77756
1 libdispatch.dylib 0x33091032 0x3308b000 + 24626
2 libdispatch.dylib 0x3309203a 0x3308b000 + 28730
3 libdispatch.dylib 0x330915ea 0x3308b000 + 26090
4 libsystem_c.dylib 0x33efa58a 0x33ec6000 + 214410
5 libsystem_c.dylib 0x33efabbc 0x33ec6000 + 215996
Thread 3 name: WebThread
Thread 3:
0 libsystem_kernel.dylib 0x33ebdc00 0x33eae000 + 64512
1 libsystem_kernel.dylib 0x33ebd758 0x33eae000 + 63320
2 CoreFoundation 0x361ef2b8 0x36179000 + 484024
3 CoreFoundation 0x361f1562 0x36179000 + 492898
4 CoreFoundation 0x36181ebc 0x36179000 + 36540
5 CoreFoundation 0x36181dc4 0x36179000 + 36292
6 WebCore 0x3594a27e 0x35944000 + 25214
7 libsystem_c.dylib 0x33ef930a 0x33ec6000 + 209674
8 libsystem_c.dylib 0x33efabb4 0x33ec6000 + 215988
Thread 0 crashed with ARM Thread State:
r0: 0x00000000 r1: 0x00066310 r2: 0x3ee32fa8 r3: 0x3e784400
r4: 0x0019a790 r5: 0x352ee670 r6: 0x36259dd8 r7: 0x2fdfe348
r8: 0x000665a8 r9: 0x3e796418 r10: 0x352ee690 r11: 0x352f46c0
ip: 0x345cc72d sp: 0x2fdfe328 lr: 0x0002d111 pc: 0x0002d12a
cpsr: 0x20000030
Please help me if you have any idea about this.
Please check if you have added such functionality that only works in IOS 5 or later & in older Ios it gives warning. That'll possibly make your Application not work in older Ios.
Hope this helps.

Cannot run existing projects on simulator after upgrading MonoTouch

I just upgraded Monotouch to latest 4.0 and MonoFramework to 2.10.1_3.macos10 and now none of my existing projects run on simulator. If I create a new project, it runs fine. How can I fix this?
If I click on the Run button in Monodevelop, the build completes successfully, but at the Application Output window I get this error:
Error connecting stdout and stderr (127.0.0.1:10001)
Couldn't register com.yourcompany.textproblem with the bootstrap server. Error: unknown error code.
This generally means that another instance of this process was already running or is hung in the debugger.Stacktrace:
at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <IL 0x0009f, 0xffffffff>
at MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x00038] in /Users/plasma/Source/iphone/monotouch/UIKit/UIApplication.cs:26
at MonoTouch.UIKit.UIApplication.Main (string[]) [0x00000] in /Users/plasma/Source/iphone/monotouch/UIKit/UIApplication.cs:31
at TextProblem.Application.Main (string[]) [0x00000] in /Users/admin/Projects/TextProblem/TextProblem/Main.cs:14
at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>
Native stacktrace:
0 TextProblem 0x000d0db5 mono_handle_native_sigsegv + 343
1 TextProblem 0x0013afad sigabrt_signal_handler + 116
2 libSystem.B.dylib 0x9027246b _sigtramp + 43
3 ??? 0xffffffff 0x0 + 4294967295
4 libSystem.B.dylib 0x902ff89d raise + 26
5 libSystem.B.dylib 0x903159bc abort + 93
6 GraphicsServices 0x03edd558 GSRegisterPurpleNamedPort + 323
7 GraphicsServices 0x03edd715 GSEventInitialize + 220
8 UIKit 0x01c17229 UIApplicationMain + 643
9 ??? 0x09e09744 0x0 + 165713732
10 ??? 0x09e0967a 0x0 + 165713530
11 ??? 0x07ff2b96 0x0 + 134163350
12 ??? 0x07ff2ae2 0x0 + 134163170
13 ??? 0x07ff2b6d 0x0 + 134163309
14 TextProblem 0x0000f5c7 mono_jit_runtime_invoke + 1332
15 TextProblem 0x001ed281 mono_runtime_invoke + 137
16 TextProblem 0x001ef968 mono_runtime_exec_main + 669
17 TextProblem 0x001eed52 mono_runtime_run_main + 843
18 TextProblem 0x000a3153 mono_jit_exec + 200
19 TextProblem 0x002a16b8 main + 4155
20 TextProblem 0x00002949 _start + 208
21 TextProblem 0x00002878 start + 40
Debug info from gdb:
/tmp/mono-gdb-commands.C9e16B:1: Error in sourced command file:
unable to debug self
=================================================================
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.
=================================================================
Try resetting the simulator. iOS Simulator -> Reset Content and Settings. Note that this will reset the simulator to its default state.
You have a process hung in the simulator, a reboot should resolve this.

Resources