Bug 59115 - Mono crashes with Acquaint sample app + Forms previewer
Summary: Mono crashes with Acquaint sample app + Forms previewer
Alias: None
Product: Android
Classification: Xamarin
Component: Designer ()
Version: 8.0 (15.4)
Hardware: Macintosh Mac OS
: --- major
Target Milestone: ---
Assignee: Bret Johnson [MSFT]
Depends on:
Reported: 2017-08-30 16:41 UTC by Bret Johnson [MSFT]
Modified: 2017-09-01 10:53 UTC (History)
3 users (show)

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

Logs (107.15 KB, application/zip)
2017-08-30 16:41 UTC, Bret Johnson [MSFT]
JVM hs_err crash (84.85 KB, text/plain)
2017-08-30 16:43 UTC, Bret Johnson [MSFT]

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 Bret Johnson [MSFT] 2017-08-30 16:41:32 UTC
Created attachment 24483 [details]

Clone the Acquaint sample app: https://github.com/xamarinhq/app-acquaint
Build it and then double click on any of the XAML files to launch the Forms previewer.

Result: Mono Android crashes and the Forms previewer doesn't work on any of the XAML pages.

I repro'ed this both on VS Mac (current GA version, with Xamarin.Android and VS Windows (15.4 preview 1, Xamarin.Android

The VS4Mac log files are attached.

Here's a snippet of the crashing thread:

Stack: [0x000070000f74c000,0x000070000f84c000],  sp=0x000070000f84ac50,  free space=1019k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [libmonosgen-2.0.dylib+0x20bc9c]  mono_property_set_value+0xc
C  [libmono-android.debug.dylib+0x154fe]  monodroid_property_set+0xbe
C  [libmono-android.debug.dylib+0x15268]  monodroid_create_appdomain+0x248
C  [libmono-android.debug.dylib+0xf159]  create_domain+0x149
C  [libmono-android.debug.dylib+0xe439]  create_and_initialize_domain+0x69
C  [libmono-android.debug.dylib+0xe89d]  Java_mono_android_Runtime_createNewContext+0x7d
j  mono.android.Runtime.createNewContext([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/ClassLoader;)I+0
j  mono.android.SessionProjectCallback.createMonoDroidContext(Ljava/lang/ClassLoader;)I+36
j  mono.android.SessionProjectCallback.getRenderClassLoaderForVersion(I)Ljava/lang/ClassLoader;+203

The Acquaint app is our de facto standard Forms sample app, which many customers may try out first. That, plus the fact it's a mono crash, points to this being a priority issue.
Comment 1 Bret Johnson [MSFT] 2017-08-30 16:43:37 UTC
Created attachment 24484 [details]
JVM hs_err crash
Comment 2 Bret Johnson [MSFT] 2017-08-31 04:34:01 UTC
I was able to generate a core dump and get more info from it.

The crash is caused by shadow_copy_dirs_prop being NULL is this code here:

monodroid_create_appdomain (struct DylibMono *mono, MonoDomain *parent_domain, const char *friendly_name, int shadow_copy, const char *shadow_directories)
	MonoClass *appdomain_setup_klass = monodroid_get_class_from_name (mono, parent_domain, "mscorlib", "System", "AppDomainSetup");
	MonoClass *appdomain_klass = monodroid_get_class_from_name (mono, parent_domain, "mscorlib", "System", "AppDomain");
	MonoMethod *create_domain = mono->mono_class_get_method_from_name (appdomain_klass, "CreateDomain", 3);
	MonoProperty *shadow_copy_prop = mono->mono_class_get_property_from_name (appdomain_setup_klass, "ShadowCopyFiles");
	MonoProperty *shadow_copy_dirs_prop = mono->mono_class_get_property_from_name (appdomain_setup_klass, "ShadowCopyDirectories");

shadow_copy_prop is set OK, but is shadow_copy_dirs_prop is NULL, causing a crash in code below that attempts to use it to set a property.

How could the ShadowCopyDirectories property not exist on the AppDomainSetup class, from mscorlib, here?
Comment 3 Bret Johnson [MSFT] 2017-08-31 15:32:33 UTC
Here's the problem & fix for it: https://github.com/xamarin/xamarin-android/pull/803
Comment 4 Bret Johnson [MSFT] 2017-09-01 00:21:33 UTC
Fixed, by Xamarin.Android PR above.
Comment 5 Alan McGovern 2017-09-01 10:53:02 UTC
I'll tag this as something we should put under CI