Bug 25207 - App crashes in some iOS devices when using a custom Logger class within a CLGeoCodeCompletion Handler with LLVM optimization on arm64 architecture
Summary: App crashes in some iOS devices when using a custom Logger class within a CLG...
Status: VERIFIED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: XI 8.4.0
Hardware: Macintosh Mac OS
: Highest normal
Target Milestone: 8.6.0
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-12-09 16:34 UTC by Kent Green [MSFT]
Modified: 2014-12-18 12:45 UTC (History)
6 users (show)

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


Attachments
Xamarin Studio logs & Crash logs from customer (2.07 MB, application/zip)
2014-12-09 16:34 UTC, Kent Green [MSFT]
Details
System.log from device (6.69 KB, application/octet-stream)
2014-12-09 22:28 UTC, Brendan Zagaeski (Xamarin Team, assistant)
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:
VERIFIED FIXED

Description Kent Green [MSFT] 2014-12-09 16:34:06 UTC
Created attachment 9012 [details]
Xamarin Studio logs & Crash logs from customer

---Overview---
From this priority desk case:
https://xamarin.desk.com/agent/case/110266

Customer wrote in with an issue where their app is crashing when testing in release on certain devices. (Please note that the issue does not appear to be reproducible when testing on the simulator or in debug mode.) 

The customer reports hitting the issue with ALL of the following settings:

---All settings needed to reproduce issue---
a) Release Build targeted to device.
b) LLVM on
c) arm64 architecture supported.
d) Log statement is not invoked on main thread.

Customer reports that changing any one of the above settings stops the crash from occurring.


---Devices that reproduce crash--- 
iPhone 5s (iOS 8.1.1)
iPhone 6  (iOS 8.1.1)

---Devices that do NOT reproduce crash---
iPhone 4s (iOS 8.1.1)
iPhone 5  (iOS 8.1.1)
iPhone 6 Plus (iOS 8.1.1)



---Build Information---
=== Xamarin Studio ===

Version 5.5.4 (build 15)
Installation UUID: 8908e49a-1f85-443a-8fbc-ebc5dd6dfd14
Runtime:
Mono 3.10.0 ((detached/92c4884)
GTK+ 2.24.23 (Raleigh theme)

Package version: 310000031

=== Apple Developer Tools ===

Xcode 6.1.1 (6611)
Build 6A2008a

=== Xamarin.Mac ===

Version:

=== Xamarin.iOS ===

Version: 8.4.0.43 (Enterprise Edition)
Hash: 840a925
Branch:
Build date: 2014-11-16 21:03:22-0500

=== Xamarin.Android ===

Version: 4.20.0.28 (Enterprise Edition)
Android SDK: /Users/phamt/android sdk/sdk
Supported Android versions:
2.1 (API level 7)
2.2 (API level 8)
2.3 (API level 10)
3.1 (API level 12)
4.0 (API level 14)
4.0.3 (API level 15)
4.4 (API level 19)
4.4.87 (API level 20)
Java SDK: /usr
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-466.1-11M4716)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-466.1, mixed mode)

=== Build Information ===

Release ID: 505040015
Git revision: f93940a35458a18052f1a25e106e62ca970d9c40
Build date: 2014-11-19 15:32:41-05
Xamarin addins: dc23cbd91a3a0e1d326328e1229e86c942a49ec8

=== Operating System ===

Mac OS X 10.10.1
Darwin EPPhamTMBP.ms.starkey.com 14.0.0 Darwin Kernel Version 14.0.0
Fri Sep 19 00:26:44 PDT 2014
root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64

---Additional Info---
Because the sample is from a customer, I will add it shortly as a private attachment.
Comment 4 Sebastien Pouliot 2014-12-09 21:35:04 UTC
@Kent what are the actual repro steps ? I assume it's enough to tap on "Get Address" ?

@Gouri can you confirm if the 8.6 alpha works fine on different 64bits devices ? (you can stop at the first one that crash)

@Zoltan I do not have the fix for #23885 but it looks like it works for me with 8.6. It could be a previous LLVM fix... however that was on a iPhone6+ which was reported as non-crashing.
Comment 5 Brendan Zagaeski (Xamarin Team, assistant) 2014-12-09 22:28:28 UTC
Created attachment 9014 [details]
System.log from device

I was able to reproduce this problem using the provided test case.


In my test environment I found that enabling Airplane mode at step 4 was very helpful. With Airplane mode enabled, the app crashed instantly after step 6. With Airplane mode disabled, I had to wait 60 seconds or more for the `ClGeoCodeReverseLocationHandler()` to get called.


## Steps used to reproduce

1. Open the test case in Xamarin Studio.


2. Double-check that the Release configuration matches the following options under "Project Options -> iOS Build":

- SDK version: Default

- Linker behavior: Link SDK assemblies only

- Packaging Options -> Optimize PNG image files for iOS: ON

- Debugging Options: OFF

- Supported architectures: ARMv7 + ARM64

- Use LLVM optimizing compiler: ON

- Use Thumb-2 instruction set for ARMv7 and ARMv7s: OFF

- Enable generic value type sharing: ON

- Runtime Options: OFF

- Internationalization: OFF


3. Build the project in the Release configuration.


4. Set the device to Airplane mode.


5. Run the app on the device.


6. Tap the "Get Address" button.



## Results

The app crashes immediately after the call to `Logger.Debug("reverse geo location handler")` in `ClGeoCodeReverseLocationHandler()` completes.

Managed crash from the device's `system.log`:

> Stacktrace:
>   at <unknown> <0xffffffff>
>   at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <0xffffffff>
>   at UIKit.UIApplication.Main (string[],intptr,intptr) <0x00033>
>   at UIKit.UIApplication.Main (string[],string,string) <0x0008f>
>   at MapApp.Application.Main (string[]) <0x0001b>
>   at (wrapper runtime-invoke) object.runtime_invoke_dynamic (intptr,intptr,intptr,intptr) <0xffffffff>
> 
> 
> 	0   MapApp                              0x00000001001dc5e8 mono_handle_native_sigsegv + 268
> 	1   MapApp                              0x00000001001e8ea8 mono_sigsegv_signal_handler + 316
> 	2   libsystem_platform.dylib            0x00000001985a895c _sigtramp + 68
> 	3   libdispatch.dylib                   0x00000001983d5a70 _dispatch_main_queue_callback_4CF + 932
> 	4   CoreFoundation                      0x00000001877658dc <redacted> + 12
> 	5   CoreFoundation                      0x0000000187763984 <redacted> + 1492
> 	6   CoreFoundation                      0x0000000187691664 CFRunLoopRunSpecific + 396
> 	7   GraphicsServices                    0x00000001907d35a4 GSEventRunModal + 168
> 	8   UIKit                               0x000000018bf96984 UIApplicationMain + 1488
> 	9   MapApp                              0x00000001000a8d88 wrapper_managed_to_native_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr + 344
> 	10  MapApp                              0x00000001000774b8 p_338_plt_UIKit_UIApplication_Main_string___intptr_intptr_llvm + 52
> 	11  MapApp                              0x0000000100077474 Xamarin_iOS__UIKit_UIApplication_Main_string___string_string + 144
> 	12  MapApp                              0x00000001000698d4 MapApp__MapApp_Application_Main_string__ + 28
> 	13  MapApp                              0x00000001001648c4 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr_0 + 116
> 	14  MapApp                              0x00000001001eafb0 mono_jit_runtime_invoke + 1264
> 	15  MapApp                              0x000000010024929c mono_runtime_invoke + 128
> 	16  MapApp                              0x000000010024d900 mono_runtime_exec_main + 404
> 	17  MapApp                              0x00000001002cad90 monotouch_main + 1752
> 	18  MapApp                              0x00000001001ab5ac main + 112
> 	19  libdyld.dylib                       0x00000001983faa08 <redacted> + 4



## Expected results

The app does not crash after the call to `Logger.Debug()`.



## Devices tested

BAD: iPhone 5s (Model A1453, A1533), iOS 8.0 (12A365)
GOOD: iPhone 4s, iOS 7.1.2 (11D257)



## Version information

Xcode 6.1 (6604), Build 6A1052d

Xamarin.iOS 8.4.0.43 (Business Edition)
Hash: 840a925
Build date: 2014-11-16 21:03:22-0500

Mac OS X 10.9.5
Comment 6 Brendan Zagaeski (Xamarin Team, assistant) 2014-12-09 22:52:41 UTC
In my test environment Xamarin.iOS 8.6.0.22 does indeed stop the problem.

## Version information (pre-release versions)
 
Xamarin Studio Version 5.7 (build 646)
Release ID: 507000646
Git revision: 4574f534cc8c822ac1a4b2f31450250afb6511d3
Build date: 2014-12-09 16:28:52-05
Xamarin addins: c3c87b666323c163f0ad02618d1753533cf0a4f9

Mono 3.12.0 ((detached/dc0ce1d)
GTK+ 2.24.23 (Raleigh theme)

Xamarin.iOS 8.6.0.22 (Business Edition)
Hash: 142934d
Build date: 2014-12-09 10:40:45-0500

Mac OS X 10.9.5
Comment 7 Sebastien Pouliot 2014-12-09 22:56:42 UTC
Thanks Brendan!

Closing the bug so QA can verify it against the next alpha/beta to get out.
Comment 8 Ram Chandra 2014-12-18 12:45:42 UTC
I am able to reproduce this issue with following builds:

Mac OS X 10.9.5
Xamarin Studio: 5.5.4 (build 15)
Mono 3.10.0 ((detached/92c4884)
GTK+ 2.24.23 (Raleigh theme)
Package version: 310000031
Xcode 6.1 (6604)
Build 6A1052d
Xamarin.iOS : 8.4.0.47 

I am able to verify this issue with following builds:

Mac OS X 10.10.0
Xamarin Studio: 5.7 (build 652)
Mono 3.12.0 ((detached/a813491)
GTK+ 2.24.23 (Raleigh theme)
Package version: 312000068
Xcode 6.1 (6604)
Build 6A1052d
Xamarin.iOS: 8.6.0.32 (Trial Edition)

To verify this issue I have used attached sample and followed the steps mentioned in Comment 5. When I tap the "Get Address" button on device I observed that Application is working fine on device without any error/exception/crash and it shows the "Error" text in front of the "Address:" label. 

Checked on iPhone 5S (8.1.2)

This issue has been fixed. Hence I am closing this issue.