Bug 37412

Summary: Attempting to JIT compile method PCLCrypto.DeriveBytes:GetBytes crash
Product: iOS Reporter: John Miller [MSFT] <john.miller>
Component: Mono runtime / AOT compilerAssignee: Zoltan Varga <vargaz>
Status: VERIFIED FIXED    
Severity: normal CC: andrewarnott, brendan.zagaeski, hvaughan3, kumpera, mono-bugs+monotouch, philipp, sunilk
Priority: ---    
Version: XI 9.4 (iOS 9.2)   
Target Milestone: (C7)   
Hardware: PC   
OS: Mac OS   
Tags: Is this bug a regression?: ---
Last known good build:

Description John Miller [MSFT] 2016-01-05 13:41:49 UTC
**Overview:**

   After updating to iOS 9.4, a crash started appearing for this customer related to something in PCLCrypto. 

**Steps to Reproduce:**

   1. Run the attached sample on an iOS device. 

**Actual Results:**

   It will crash on launch. 

   See attached stacktrace.

**Expected Results:**

   No crash.

**Build Date & Platform:**

   XI 9.4.0.0
   Xcode 7.2
Comment 4 Zoltan Varga 2016-01-05 17:38:23 UTC
Fixed in mono master f04a83ca39e0a4bbf01bcd96236e3017e85390cf.
Comment 5 Brendan Zagaeski (Xamarin Support) 2016-01-06 23:46:45 UTC
## Regression status: not a regression in Xamarin or Xcode

I tested the following versions in the Release configuration with LLVM enabled and the linker disabled. All of the versions failed with the same exception.

(For completeness, I also tested all of these versions with the linker set to link SDK assemblies only. The results were the same.)


### Mono 4.2.2 (explicit/7b87787), Xcode 7.1

BAD: Xamarin.iOS 9.2.1.54 (eb4c1ef) ("Cycle 6 – Service Release 0")
BAD: Xamarin.iOS 9.1.0.27 (1f068b4) ("Cycle 5 – Service Release 5")


### Mono 4.0.5 (detached/1d8d582), Xcode 7.1

BAD: Xamarin.iOS 9.1.0.27 (1f068b4) ("Cycle 5 – Service Release 5")


### Mono 3.12.1 (detached/0849ec7), Xcode 6.4

BAD: Xamarin.iOS 8.9.1.3 (f7736a4) ("Cycle 4, iOS 8.3")

(I had to downgrade Xamarin.Forms for API compatibility in this configuration, but even after that change the app still crashed with the same exception message.)





## Regression status: an old problem in Xamarin, but only exposed by newer versions of the PCLCrypto NuGet

On a hunch, I tried downgrading the PCLCrypto NuGet package, and that _did_ show a change in behavior between different versions:

BAD:  PCLCrypto 1.0.80       (October, 2015)
GOOD: PCLCrypto 1.0.2.15130  (May, 2015)


So it seems this problem has been present in Xamarin for a while, but it only became a problem for the PCLCrypto NuGet package more recently.
Comment 6 Hines Vaughan III 2016-01-20 13:44:13 UTC
Could this bug be reopened as it may not be fixed judging from the previous comment by Brendan. Thanks.
Comment 7 Zoltan Varga 2016-01-20 14:02:33 UTC
It is fixed, the fix is not in the versions tested above.
Comment 8 Brendan Zagaeski (Xamarin Support) 2016-01-20 18:46:14 UTC
I will set the tentative target milestone to "Cycle 7" to help indicate that the fix will likely be included in "Cycle 7".

(The target milestone can be updated for accuracy again in the future if necessary.)


See the first entry in the release blog [1] as well as the "Xamarin Release Cycles" article [2] for more information about the term "cycle."

[1] https://releases.xamarin.com/welcome-to-the-xamarin-release-blog/
[2] http://tirania.org/blog/archive/2015/Sep-01.html
Comment 9 Hines Vaughan III 2016-04-06 19:08:30 UTC
Can this still be expected to be available in Cycle 7? Thanks.
Comment 10 Zoltan Varga 2016-04-06 19:31:11 UTC
Its going to be in cycle7.
Comment 11 Sunil Kumar 2016-05-20 14:13:25 UTC
I have checked this issue with Cycle 7 latest builds. To verify this issue I downloaded the attached sample, enable the LLVM compiling and run it on iOS device and observed that now this issue works fine. Now it is not showing any exception and sample launches successfully on iOS devices.

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

Hence closing this issue.

Environment info:

Device info:
iPhone 6S Plus (iOS 9.3.1)
iPad Pro (iOS 9.3.1)


=== Xamarin Studio Enterprise ===

Version 6.0 (build 5165)
Installation UUID: 956d7bf6-5e53-42e5-9fb4-c7d91835f9d7
Runtime:
	Mono 4.4.0 (mono-4.4.0-branch/0f5fdf2) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 404000168

=== Xamarin.Profiler ===

Version: 0.33.1
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Apple Developer Tools ===

Xcode 7.3.1 (10188.1)
Build 7D1014

=== Xamarin.Mac ===

Version: 2.8.0.318 (Xamarin Enterprise)

=== Xamarin.Android ===

Version: 6.1.0.68 (Xamarin Enterprise)
Android SDK: /Users/xamarin_360/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.3   (API level 10)
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.4   (API level 19)
		5.1   (API level 22)
		6.0   (API level 23)

SDK Tools Version: 25.1.3
SDK Platform Tools Version: 23.1
SDK Build Tools Version: 23.0.3

Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Xamarin Android Player ===

Version: 0.6.5
Location: /Applications/Xamarin Android Player.app

=== Xamarin.iOS ===

Version: 9.8.0.318 (Xamarin Enterprise)
Hash: efefc1e
Branch: cycle7
Build date: 2016-05-13 17:19:05-0400

=== Build Information ===

Release ID: 600005165
Git revision: b44eb696fa41a04696a84d6af7fed9aa494e5580
Build date: 2016-05-19 02:59:52-04
Xamarin addins: c7761d054f38e9a210822aba6356398af0c36fa9
Build lane: monodevelop-lion-cycle7

=== Operating System ===

Mac OS X 10.11.4
Darwin Xamarin-360s-iMac.local 15.4.0 Darwin Kernel Version 15.4.0
    Fri Feb 26 22:08:05 PST 2016
    root:xnu-3248.40.184~3/RELEASE_X86_64 x86_64