Bug 25646

Summary: Microsoft_FSharp_Core_LanguagePrimitives_HashCompare_GenericCompare causes assertion
Product: iOS Reporter: Frank A. Krueger <fak>
Component: XI runtimeAssignee: Zoltan Varga <vargaz>
Status: VERIFIED FIXED    
Severity: critical CC: gouri.kumari, miguel, mohitk, mono-bugs+monotouch, pj.beaman, rolf, sebastien, udhams
Priority: High    
Version: XI 8.6.0   
Target Milestone: 8.6.0   
Hardware: PC   
OS: Mac OS   
Tags: Is this bug a regression?: ---
Last known good build:
Attachments: Sample App
NoiseAnimation screenshot

Description Frank A. Krueger 2014-12-29 20:15:27 UTC
When trying to run an F# app on an iPhone 6 Plus. This is 100% reproducible. Just load the program.

AppDelegate source code here: 

https://gist.github.com/praeclarum/3074dc240b138a2a9c32



<Warning>: Found new TLS offset at 224
<Error>: assertion failed: 12B440: libxpc.dylib + 71820 [A4F17798-F3DE-3FBC-85E3-F569762F0EB9]: 0x7d
<Warning>: critical: Stacktrace:
<Warning>: critical:   at <unknown> <0xffffffff>
<Warning>: critical:   at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <0xffffffff>
<Warning>: critical:   at UIKit.UIApplication.Main (string[],intptr,intptr) [0x00005] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:62
<Warning>: critical:   at UIKit.UIApplication.Main (string[],string,string) [0x0001c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:45
<Warning>: critical:   at NoiseAnimation.Main.main (string[]) [0x00000] in /Users/fak/Dropbox/Projects/NoiseAnimation/AppDelegate.fs:81
<Warning>: critical:   at (wrapper runtime-invoke) object.runtime_invoke_dynamic (intptr,intptr,intptr,intptr) <0xffffffff>
<Warning>: critical:
<Warning>: critical: 	0   NoiseAnimation                      0x0000000100dbf0d4 mono_handle_native_sigsegv + 268
<Warning>: critical: 	1   NoiseAnimation                      0x0000000100dc8efc mono_sigsegv_signal_handler + 316
<Warning>: critical: 	2   libsystem_platform.dylib            0x000000019345495c _sigtramp + 68
<Warning>: critical: 	3   NoiseAnimation                      0x0000000100888330 Microsoft_FSharp_Core_LanguagePrimitives_HashCompare_GenericCompare_cont_985_1_Microsoft_FSharp_Core_LanguagePrimitives_HashCompare_GenericComparer_object_object_System_IComparable_Microsoft_FSharp_Core_Unit + 1360
<Warning>: critical: 	4   NoiseAnimation                      0x00000001000d2bf8 Microsoft_FSharp_Core_LanguagePrimitives_HashCompare_GenericComparisonWithComparerIntrinsic_System_nfloat_System_Collections_IComparer_System_nfloat_System_nfloat + 232
<Warning>: critical: 	5   NoiseAnimation                      0x00000001000d29b4 Microsoft_FSharp_Core_LanguagePrimitives_HashCompare_GenericLessThanIntrinsic_System_nfloat_System_nfloat_System_nfloat + 308
<Warning>: critical: 	6   NoiseAnimation                      0x00000001000d03c0 NoiseAnimation_NoiseView_Draw_CoreGraphics_CGRect + 784
<Warning>: critical: 	7   NoiseAnimation                      0x00000001000d2528 wrapper_runtime_invoke__Module_runtime_invoke_void__this___CGRect_object_intptr_intptr_intptr + 728
<Warning>: critical: 	8   NoiseAnimation                      0x0000000100dcaf68 mono_jit_runtime_invoke + 1108
<Warning>: critical: 	9   NoiseAnimation                      0x0000000100e1a820 mono_runtime_invoke + 128
<Warning>: critical: 	10  NoiseAnimation                      0x0000000100d91308 native_to_managed_trampoline_1 + 240
<Warning>: critical: 	11  NoiseAnimation                      0x0000000100d91ef8 -[NoiseAnimation_NoiseView drawRect:] + 76
<Warning>: critical: 	12  UIKit                               0x0000000186d0e60c <redacted> + 392
<Warning>: critical: 	13  QuartzCore                          0x0000000186611c14 <redacted> + 284
<Warning>: critical: 	14  QuartzCore                          0x00000001865fc340 <redacted> + 2580
<Warning>: critical: 	15  QuartzCore                          0x00000001865fb91c <redacted> + 108
<Warning>: critical: 	16  QuartzCore                          0x00000001865fb4a4 <redacted> + 1276
<Warning>: critical: 	17  QuartzCore                          0x00000001865dc75c <redacted> + 244
<Warning>: critical: 	18  QuartzCore                          0x00000001865dc414 <redacted> + 44
<Warning>: critical: 	19  QuartzCore                          0x00000001865dbc08 <redacted> + 276
<Warning>: critical: 	20  QuartzCore                          0x00000001865db98c <redacted> + 436
<Warning>: critical: 	21  UIKit                               0x0000000186f16dbc <redacted> + 60
<Warning>: critical: 	22  UIKit                               0x0000000186f17c68 <redacted> + 2780
<Warning>: critical: 	23  UIKit                               0x0000000186f15dec <redacted> + 184
<Warning>: critical: 	24  FrontBoardServices                  0x000000018a74962c <redacted> + 28
<Warning>: critical: 	25  CoreFoundation                      0x0000000182492a28 <redacted> + 20
<Warning>: critical: 	26  CoreFoundation                      0x0000000182491b30 <redacted> + 312
<Warning>: critical: 	27  CoreFoundation                      0x0000000182490154 <redacted> + 1756
<Warning>: critical: 	28  CoreFoundation                      0x00000001823bd0a4 CFRunLoopRunSpecific + 396
<Warning>: critical: 	29  UIKit                               0x0000000186cf73c8 <redacted> + 552
<Warning>: critical: 	30  UIKit                               0x0000000186cf23c0 UIApplicationMain + 1488
<Warning>: critical: 	31  NoiseAnimation                      0x0000000100337c88 wrapper_managed_to_native_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr + 344
<Warning>: critical: 	32  NoiseAnimation                      0x000000010030b8c4 UIKit_UIApplication_Main_string___intptr_intptr + 52
<Warning>: critical: 	33  NoiseAnimation                      0x000000010030b870 UIKit_UIApplication_Main_string___string_string + 192
<Warning>: critical: 	34  NoiseAnimation                      0x00000001000d11f8 NoiseAnimation_Main_main_string__ + 120
<Warning>: critical: 	35  NoiseAnimation                      0x000000010027dd84 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 116
<Warning>: critical: 	36  NoiseAnimation                      0x0000000100dcb004 mono_jit_runtime_invoke + 1264
<Warning>: critical: 	37  NoiseAnimation                      0x0000000100e1a820 mono_runtime_invoke + 128
<Warning>: critical: 	38  NoiseAnimation                      0x0000000100e1e9a8 mono_runtime_exec_main + 404
<Warning>: critical: 	39  NoiseAnimation                      0x0000000100e849ac xamarin_main + 2120
<Warning>: critical: 	40  NoiseAnimation                      0x0000000100d92dd4 main + 112
<Warning>: critical: 	41  libdyld.dylib                       0x00000001932a6a08 <redacted> + 4







=== Xamarin Studio ===

Version 5.7 (build 660)
Installation UUID: fce13fdd-e8e3-48ef-99f1-4acbb06f0240
Runtime:
	Mono 3.12.0 ((detached/a813491)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312000068

=== Apple Developer Tools ===

Xcode 6.1.1 (6611)
Build 6A2008a

=== Xamarin.iOS ===

Version: 8.6.0.41 (Enterprise Edition)
Hash: 2c57f4e
Branch: 
Build date: 2014-12-18 16:42:49-0500

=== Xamarin.Android ===

Version: 4.20.0.28 (Enterprise Edition)
Android SDK: /Users/fak/Library/Developer/Xamarin/android-sdk-mac_x86
	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.3   (API level 18)
		4.4   (API level 19)
Java SDK: /usr
java version "1.8.0_20-ea"
Java(TM) SE Runtime Environment (build 1.8.0_20-ea-b23)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b22, mixed mode)

=== Xamarin.Mac ===

Version: 1.11.3.0 (Enterprise Edition)

=== Build Information ===

Release ID: 507000660
Git revision: 6a74f9bdb90d9415b597064d815c9be38b401fee
Build date: 2014-12-18 00:38:00-05
Xamarin addins: 57be0f5e1433cb58b70ea9b52e9dc77ad791be40

=== Operating System ===

Mac OS X 10.10.2
Darwin muon.local 14.1.0 Darwin Kernel Version 14.1.0
    Sun Nov 30 22:30:35 PST 2014
    root:xnu-2782.10.66~2/RELEASE_X86_64 x86_64
Comment 1 Udham Singh 2014-12-30 05:58:35 UTC
Created attachment 9206 [details]
Sample App

I have checked this issue with the help of code provided in bug description and able to reproduce this. To reproduce this issue I have followed the steps below.

1. Create a F# iOS Empty Project via 'File ->New ->Solutions... ->F# ->iOS -> Unified API ->iPhone ->Empty Project'.
2. Open file AppDelegate.fs and implement the code given in bug description.
3. Run the application on iOS device and observed that application is deployed successfully on device but getting crashed when it's launched on device.

Screencast : http://www.screencast.com/t/zjCkGKtKY0dg

Application Output : https://gist.github.com/Udham1/63d7993703b4e0545b63

Note : I have checked this issue with iOS device iPhone 6(8.0.2) and iPhone 5S(8.1.2) and able to reproduce this with both devices. With simulator this is working fine. I am attaching a sample app which I have created to reproduce this issue.

Environment Info :

=== Xamarin Studio ===

Version 5.7 (build 660)
Installation UUID: ce927b2a-2c07-44c5-b186-09cfdafba6dc
Runtime:
	Mono 3.12.0 ((detached/a813491)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312000068

=== Apple Developer Tools ===

Xcode 6.1.1 (6611)
Build 6A2008a

=== Xamarin.iOS ===

Version: 8.6.0.41 (Enterprise Edition)
Hash: 2c57f4e
Branch: 
Build date: 2014-12-18 16:42:49-0500

=== Build Information ===

Release ID: 507000660
Git revision: 6a74f9bdb90d9415b597064d815c9be38b401fee
Build date: 2014-12-18 00:38:00-05
Xamarin addins: 57be0f5e1433cb58b70ea9b52e9dc77ad791be40

=== Operating System ===

Mac OS X 10.9.4
Darwin Xamarin76s-Mac-mini.local 13.3.0 Darwin Kernel Version 13.3.0
    Tue Jun  3 21:27:35 PDT 2014
    root:xnu-2422.110.17~1/RELEASE_X86_64 x86_64
Comment 2 Miguel de Icaza [MSFT] 2014-12-30 19:17:25 UTC
This is caused by nfloat comparisons.
Comment 3 Rolf Bjarne Kvinge [MSFT] 2015-01-05 05:00:40 UTC
Zoltan, this looks like an AOT issue.
Comment 4 Zoltan Varga 2015-01-05 15:23:03 UTC
Fixed in mono master 1b9729dbf67c337d016bd7635e20bf81b61cf63f. Should this be backported ? Without it, f# is not going to work on arm64.
Comment 5 Rolf Bjarne Kvinge [MSFT] 2015-01-06 04:06:22 UTC
Looping in Sebastien, re comment 4.
Comment 6 Sebastien Pouliot 2015-01-06 07:55:38 UTC
@Zoltan backport requests on frozen release branches needs to be made on the release thread emails (with answer the four questions).
Comment 7 Sebastien Pouliot 2015-01-06 08:34:27 UTC
c.c. QA as I expected we had samples/tests using F# run on devices (wrt comment #4).
Comment 8 Zoltan Varga 2015-01-06 09:09:42 UTC
The failure is somewhat random, but I expect most f# apps to run into it, its related to parameter passing for tail calls.
Comment 9 Mohit Kheterpal 2015-01-06 12:11:15 UTC
I have checked this issue and observed that F# default template is working fine and its also woking fine when we select arm64 in project properties i.e. application launches on device successfully.

This issue only occur when we use code mention in bug description.
Comment 10 Frank A. Krueger 2015-01-06 12:43:37 UTC
Regarding Comment #9: while it's nice that the default template "works" (it doesn't do anything), I have yet to be able to write a non-trivial app in F# Unified due to this bug.
Comment 11 Sebastien Pouliot 2015-01-06 13:11:40 UTC
@Frank, fully agreed :) What Mohit did (templates) is not enough to verify this - but it's not the only tests being executed.

We're testing Zoltan's fix right now. My question (comment #7) was to figure out why this was not catched before (and what we need to do/add so it does not happen again).
Comment 12 Sebastien Pouliot 2015-01-06 15:07:43 UTC
Backported to monotouch-8.6.-0-branch in eb24bdcf5cba2c12b673a07e0a8cce368b9563b3
Closing for QA verification
Comment 13 GouriKumari 2015-01-06 15:27:03 UTC
Created attachment 9257 [details]
NoiseAnimation screenshot

I retested the bug with Xamarin.iOS 8.6.0.49.pkg and the app got deployed and executed successfully on a iPhone6Plus 8.1.1 device.

Test Results:
App crashed on iPhone6Plus 8.1.1 device with Xamarin.iOS 8.6.0.48.pkg
Crash Log: https://gist.github.com/GouriKumari/5b71f906482ea421dc90
Build Log: https://gist.github.com/GouriKumari/9fadcd23e81114a3a5d0

Crash got resolved with Xamarin.iOS 8.6.0.49.pkg
Build log: https://gist.github.com/GouriKumari/c8ed27e5bc52945f1abe
Screenshot attached.
Comment 14 Mohit Kheterpal 2015-01-07 12:49:52 UTC
I have checked this issue using NoiseAnimation sample and now this sample does not crash and it deploy/launch on device successfully.

Hence closing this issue.

Environment info :
=== Xamarin Studio ===

Version 5.7 (build 642)
Installation UUID: 45555ffd-f3f0-4f29-9543-e369d711ab7d
Runtime:
	Mono 3.12.0 ((detached/a813491)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312000068

=== Apple Developer Tools ===

Xcode 6.1 (6604)
Build 6A1052d

=== Xamarin.iOS ===

Version: 8.6.0.50 (Business Edition)
Hash: 561dfed
Branch: 
Build date: 2015-01-06 17:56:14-0500

=== Xamarin.Android ===

Version: 4.20.0.28 (Trial Edition)
Android SDK: /Users/xamarin77/Desktop/android-sdk-macosx_êèéæâàçéè€ÿëïœ
	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.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

=== Xamarin.Mac ===

Version: 1.11.3.0 (Trial Edition)

=== Build Information ===

Release ID: 507000642
Git revision: 914f993ae891b032445690bbc37d330188a1d80b
Build date: 2014-12-08 17:21:36-05
Xamarin addins: aebff2d6b44f5935fe2988435a34aff68704640f

=== Operating System ===

Mac OS X 10.9.5
Darwin Xamarin77s-Mac-mini.local 13.4.0 Darwin Kernel Version 13.4.0
    Sun Aug 17 19:50:11 PDT 2014
    root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64