Bug 55087 - System.NotSupportedException: Stack walks are not supported on this platform - System.Reflection.MethodBase.GetCurrentMethod
Summary: System.NotSupportedException: Stack walks are not supported on this platform ...
Alias: None
Product: Android
Classification: Xamarin
Component: Mono runtime / AOT Compiler ()
Version: unspecified
Hardware: Macintosh Mac OS
: Highest blocker
Target Milestone: 15.2.2
Assignee: Zoltan Varga
: 55602 56233 ()
Depends on:
Reported: 2017-04-12 13:29 UTC by Chris Riesgo
Modified: 2017-05-26 20:01 UTC (History)
20 users (show)

Tags: 15.2KI
Is this bug a regression?: Yes
Last known good build: XA 7.2.x

Visual Studio install details (1.93 KB, text/plain)
2017-04-12 13:29 UTC, Chris Riesgo
Xamarin.Android Repro App (31.78 KB, application/zip)
2017-04-12 13:29 UTC, Chris Riesgo
Preview 10 VS for Mac Details (1.95 KB, text/plain)
2017-05-08 23:35 UTC, Chris Riesgo
API23 x86_64 Google Emulator (1.11 KB, text/plain)
2017-05-08 23:36 UTC, Chris Riesgo
Android Crash Log (31.80 KB, text/plain)
2017-05-09 01:32 UTC, Chris Riesgo
Logs Generated when issue is reproduced (11.27 KB, application/x-zip-compressed)
2017-05-15 13:29 UTC, Saurabh Paunikar
IDE Logs (4.79 KB, application/zip)
2017-05-16 09:29 UTC, Pratik Lad

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:

Description Chris Riesgo 2017-04-12 13:29:12 UTC
Created attachment 21468 [details]
Visual Studio install details

In the current preview of Mono 5, there seems to be a bug, regression, or missing functionality around "System.Reflection.MethodBase.GetCurrentMethod().DeclaringType;". 

I consistently receive this exception:

System.NotSupportedException: Stack walks are not supported on this platform.
  at (wrapper managed-to-native) System.Reflection.MethodBase:GetCurrentMethod ()

I'm attaching a sample Xamarin.Android app that demonstrates the issue. This same code works fine in the latest stable version of Mono.
Comment 1 Chris Riesgo 2017-04-12 13:29:51 UTC
Created attachment 21469 [details]
Xamarin.Android Repro App
Comment 2 Zoltan Varga 2017-04-24 20:32:12 UTC
Does this  happen on a simulator, or on a real device ?
Comment 3 Chris Riesgo 2017-04-24 20:52:44 UTC
For sure on a Google API 23 emulator
Comment 4 Chris Riesgo 2017-04-25 13:36:13 UTC
@Zoltan - Some additional info I gathered this morning

Also crashes on:
Google API 24 emulator
Google API 25 emulator

NO crash on:
Moto E 2nd gen API 22 (debug & release build configurations)
Nexus 5 hardware API 23 (debug & release build configurations)
Nexus 6P hardware API 25  (debug & release build configurations)
Comment 5 Chris Riesgo 2017-05-03 12:59:23 UTC
@Zoltan - I might have some additionally useful information. 

Running on x86_64 emulator image
x86 ABI selected + x86_64 ABI unselected       => WORKS!!
x86 ABI unselected + x86_64 ABI selected       => crash
Comment 6 Chris Riesgo 2017-05-08 23:35:21 UTC
Created attachment 22012 [details]
Preview 10 VS for Mac Details
Comment 7 Chris Riesgo 2017-05-08 23:36:36 UTC
Created attachment 22013 [details]
API23 x86_64 Google Emulator

Here's one example of an Android emulator where the repro app crashes. Please note that you need to click the button to observe the crash.
Comment 8 Chris Riesgo 2017-05-08 23:57:03 UTC
Here's the crash stack:

CrashTest Exception: System.NotSupportedException: Stack walks are not supported on this platform.
  at (wrapper managed-to-native) System.Reflection.MethodBase:GetCurrentMethod ()
  at CrashTest.MainActivity.GetDeclaringType () [0x00002] in /Users/chrisr/Downloads/CrashTest/CrashTest/MainActivity.cs:37
Comment 9 Jon Goldberger [MSFT] 2017-05-09 01:30:54 UTC
Setting as confirmed as I can reproduce this issue when running the test project on a Google x86_64 emulator running Marshmallow. 

## Steps to reproduce:

1. Load the Repro app
2. Open the Android Project Options->Android Build->Advanced tab
3. Deselect all supported ABIs EXCEPT x86_64
4. Build and run the app to an x86_64 emulator
5. Click the button

Expected result: Button's text will be updated to say "1 MainActivity Clicks!"

Actual result: App crashes with exception and stack trace below:

>System.NotSupportedException: Stack walks are not supported on this platform.
>  at at (wrapper managed-to-native) System.Reflection.MethodBase:GetCurrentMethod ()
>  at CrashTest.MainActivity.GetDeclaringType () [0x00022] in /Users/jongoldberger/Downloads/CrashTest/CrashTest/MainActivity.cs:42
>  at CrashTest.MainActivity+<>c__DisplayClass1_0.<OnCreate>b__0 (System.Object <p0>, System.EventArgs <p1>) [0x00001] in /Users/jongoldberger/Downloads/CrashTest/CrashTest/MainActivity.cs:28
>  at Android.Views.View+IOnClickListenerImplementor.OnClick (Android.Views.View v) [0x00011] in <33e6e739ac344166b157e323586f11a1>:0
>  at Android.Views.View+IOnClickListenerInvoker.n_OnClick_Landroid_view_View_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_v) [0x0000f] in <33e6e739ac344166b157e323586f11a1>:0
>  at at (wrapper dynamic-method) System.Object:d5595756-92bd-4e78-9420-4ec888bd7ea4 (intptr,intptr,intptr)

## Environment

=== Visual Studio for Mac Preview ===

Version Preview 10 (7.0 build 3051)
Installation UUID: f86726f2-bd5d-4610-867e-44e82f306ca2
	Mono (2017-02/1d0445b) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 500000094

=== NuGet ===


=== .NET Core ===

Runtime: /usr/local/share/dotnet/dotnet
SDK: /usr/local/share/dotnet/sdk/1.0.1/Sdks
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.0.0/lib/mono/msbuild/15.0/bin/Sdks

=== Xamarin.Profiler ===

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

=== Apple Developer Tools ===

Xcode 8.3.2 (12175)
Build 8E2002

=== Xamarin.Android ===

Version: (Visual Studio Enterprise)
Android SDK: /Users/jongoldberger/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		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)
		5.0   (API level 21)
		5.1   (API level 22)
		6.0   (API level 23)
		7.0   (API level 24)
		7.1   (API level 25)

SDK Tools Version: 25.2.5
SDK Platform Tools Version: 25.0.5
SDK Build Tools Version: 25.0.2

Java SDK: /usr
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)

Android Designer EPL code available here:

=== Xamarin Inspector ===

Version: 1.2.2
Hash: b71b035
Branch: d15-1
Build date: Fri, 21 Apr 2017 17:57:12 GMT

=== Xamarin.Mac ===

Version: (Visual Studio Enterprise)

=== Xamarin.iOS ===

Version: (Visual Studio Enterprise)
Hash: 30b6e87e
Branch: d15-2
Build date: 2017-04-28 17:17:13-0400

=== Build Information ===

Release ID: 700003051
Git revision: e5296061de5c6b093fb59668526728f2b82caa91
Build date: 2017-05-01 09:58:05-04
Xamarin addins: 7123ae956f3089f398cc9eae6bba94037ca896e6
Build lane: monodevelop-lion-d15-2

=== Operating System ===

Mac OS X 10.12.4
Darwin 16.5.0 Darwin Kernel Version 16.5.0
    Fri Mar  3 16:52:33 PST 2017
    root:xnu-3789.51.2~3/RELEASE_X86_64 x86_64
Comment 10 Chris Riesgo 2017-05-09 01:32:10 UTC
Created attachment 22014 [details]
Android Crash Log

Seems the issue is specific to Android version 7.3.x. 

If I upgrade ONLY Visual Studio for Mac to Preview 10 (leaving all other SDKs on Stable), my sample app works. If I then update Android from 7.2.x to 7.3.x, then the app begins to crash.
Comment 11 Zoltan Varga 2017-05-10 01:18:25 UTC
Comment 12 Zoltan Varga 2017-05-10 15:01:02 UTC
Should be fixed on mono 2017-02 branch by 1298269b88479747947d332c8ae7c0e8222a3b8c.

Could somebody bump xam.android to that revision or cherry-pick-it into a branch ?
Comment 13 Ashley Gazich [MSFT] 2017-05-11 17:37:32 UTC
*** Bug 56233 has been marked as a duplicate of this bug. ***
Comment 14 Brendan Zagaeski (Xamarin Team, assistant) 2017-05-11 22:02:44 UTC
## Additional tallying

4 other users: https://forums.xamarin.com/discussion/92934/ (2017-04-11 to 2017-05-11)
3 other users: https://forums.xamarin.com/discussion/92937/ (2017-04-11 to 2017-05-10)
1 other user:  https://forums.xamarin.com/discussion/93430/ (2017-04-18 to 2017-04-27)

0 other users: https://forums.xamarin.com/discussion/93975/ (2017-04-24, from the reporter of this bug)
Comment 15 Saurabh Paunikar 2017-05-15 13:28:41 UTC
Reopening this issue as in mono version I found that application crashes

In comment 9 it is mentioned that 
Expected result : Button's text will be updated to say "1 MainActivity Clicks!"  when button is clicked  

But it was found that application crashes when button is clicked

ScreenCast link:https://www.screencast.com/t/LC0HaXJABl
Comment 16 Saurabh Paunikar 2017-05-15 13:29:48 UTC
Created attachment 22168 [details]
Logs Generated when issue is reproduced
Comment 17 Ludovic Henry 2017-05-15 15:07:11 UTC
@Saurabh you didn't test the fix as the android version you have is too old. First a bump on Android need to happen before you test it.
Comment 18 Pratik Lad 2017-05-16 09:15:37 UTC
Verified the bug on build :-
Visual Studio Enterprise 2017 for Mac Version 7.0.1 (build 2)
Xamarin.Android Version:
Xamarin.iOS Version:
Xamarin.Mac Version:

Screen cast link :-

Build Information :-

As I have verified this bug can you please mark the bug resolved so that i can mark it as verified.

Comment 19 Pratik Lad 2017-05-16 09:29:37 UTC
Created attachment 22189 [details]
IDE Logs
Comment 20 Mobigital 2017-05-17 19:00:08 UTC
I am experiencing the same issue, is there a workaround or expected fix date?
Comment 21 Brendan Zagaeski (Xamarin Team, assistant) 2017-05-17 19:07:19 UTC
@Mobigtal, a workaround is to use an x86 Android emulator rather than an x86_64 Android emulator or to deselect the x86_64 Android ABI, as mentioned in Comment 5.  The candidate fix as verified on Comment 18 and Comment 19 is targeted to the Xamarin 15.2.2 release as indicated by the Target Milestone field of the bug.  The Xamarin 15.2.2 release is tentatively scheduled for release by the end of this week.
Comment 22 Rodrigo Kumpera 2017-05-26 20:01:16 UTC
*** Bug 55602 has been marked as a duplicate of this bug. ***