Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Xamarin.Android.Build.Tasks] Improve error text #1

Closed
wants to merge 1 commit into from

Conversation

brendanzagaeski
Copy link
Owner

Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=43245

I wouldn't be surprised if this download mechanism gets redesigned at
some point in the future. That could make these suggested changes
obsolete. But I suspect the current download mechanism will be around
for at least a little while longer, so adding these corrections and
improvements will still be helpful.

  • ErrorMessage():
  • Check for InstallInstructions first. If custom instructions
    are available via that property, they should take precedence
    over the more generic message for PackageName.
  • Rewrite the message for PackageName. The old error was
    incorrect. (For example, there was no "SDK installer" that
    would help resolve the error.) Additionally the new if
    statement in AddAttributeValue() removes some redundant
    appearances of this error, so the message can now provide more
    specific instructions.
  • AddAttributeValue():
  • Add if (sourceUrl.Name == null) to avoid logging unnecessary
    additional errors. MakeSureLibraryIsInPlace() now provides
    appropriate errors for each possible failure when
    sourceUrl.Name != null, so additional errors are only needed
    if sourceUrl.Name == null.
  • ExtractArchive():
  • Update the error message to account for the MD5 file names and
    the "zips" folder that were added in July 2015 (monodroid/master
    e8737f15c5e6f71f01f566475865a2cb34bfdfc9). Also remove the
    phrase "Please download" because re-downloading will not
    necessarily help with problems unzipping the file.
  • MakeSureLibraryIsInPlace():
  • Update the error message to account for the MD5 file names and
    the "zips" folder that were added in July 2015 (monodroid/master
    e8737f15c5e6f71f01f566475865a2cb34bfdfc9).
  • Add a new explicit error with code "XA5217" for the case where a
    .zip file is extracted without error but is missing an expected
    nested archive. The old logic allowed the build process to
    continue even if all 3 attempts failed, and that could lead to
    some confusing error messages later in the build.
  • Execute():
  • Add parentheses and "Details:" to the second part of each error
    message because the file name of the missing item is usually
    much less important than the first part of the error message.

Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=43245

I wouldn't be surprised if this download mechanism gets redesigned at
some point in the future.  That could make these suggested changes
obsolete.  But I suspect the current download mechanism will be around
for at least a little while longer, so adding these corrections and
improvements will still be helpful.

-   `ErrorMessage()`:

    -   Check for `InstallInstructions` first.  If custom instructions
        are available via that property, they should take precedence
        over the more generic message for `PackageName`.

    -   Rewrite the message for `PackageName`.  The old error was
        incorrect.  (For example, there was no "SDK installer" that
        would help resolve the error.)  Additionally the new `if`
        statement in `AddAttributeValue()` removes some redundant
        appearances of this error, so the message can now provide more
        specific instructions.

-   `AddAttributeValue()`:

    -   Add `if (sourceUrl.Name == null)` to avoid logging unnecessary
        additional errors.  `MakeSureLibraryIsInPlace()` now provides
        appropriate errors for each possible failure when
        `sourceUrl.Name != null`, so additional errors are only needed
        if `sourceUrl.Name == null`.

-   `ExtractArchive()`:

    -   Update the error message to account for the MD5 file names and
        the "zips" folder that were added in July 2015 (monodroid/master
        e8737f15c5e6f71f01f566475865a2cb34bfdfc9).  Also remove the
        phrase "Please download" because re-downloading will not
        necessarily help with problems unzipping the file.

-   `MakeSureLibraryIsInPlace()`:

    -   Update the error message to account for the MD5 file names and
        the "zips" folder that were added in July 2015 (monodroid/master
        e8737f15c5e6f71f01f566475865a2cb34bfdfc9).

    -   Add a new explicit error with code "XA5217" for the case where a
        .zip file is extracted without error but is missing an expected
        nested archive.  The old logic allowed the build process to
        continue even if all 3 attempts failed, and that could lead to
        some confusing error messages later in the build.

-   `Execute()`:

    -   Add parentheses and "Details:" to the second part of each error
        message because the file name of the missing item is usually
        much less important than the first part of the error message.

Examples of how to hit each error message
=========================================

Setup
-----

1.  Create a new "Android > App > Blank Android App" in Xamarin Studio
    on Mac.

2.  Add the Xamarin.Android.Support.v4 NuGet package, version 23.4.0.1.

3.  Move any existing cached downloads of the Java library dependencies
    out of the way (or delete them):

    -   "$HOME/.local/share/Xamarin/Xamarin.Android.Support.v4/23.4.0.0"
    -   "$HOME/.local/share/Xamarin/zips/F16A3455987DBAE5783F058F19F7FCDF.zip"

Results when the download fails due to an exception
---------------------------------------------------

For example, disconnect the computer from the internet and then build
the project.

> error XA5208: Download failed. Please download
> https://dl-ssl.google.com/android/repository/android_m2repository_r32.zip
> and copy it to
> /Users/macuser/.local/share/Xamarin/zips/F16A3455987DBAE5783F058F19F7FCDF.zip

> error XA5208: Reason: Error: NameResolutionFailure

Results when the downloaded file can't be unzipped
--------------------------------------------------

For example, manually download the file, copy it into place, and then
disable read permissions (`chmod a-r`) on the file.

> error XA5209: Unzipping failed while attempting to extract
> /Users/macuser/.local/share/Xamarin/zips/F16A3455987DBAE5783F058F19F7FCDF.zip
> into
> /Users/macuser/.local/share/Xamarin/Xamarin.Android.Support.v4/23.4.0.0/content

> error XA5209: Reason: File
> /Users/macuser/.local/share/Xamarin/zips/F16A3455987DBAE5783F058F19F7FCDF.zip
> could not be opened

Results when extracting an embeddedArchive fails 3 times
--------------------------------------------------------

For example, replace
"$HOME/.local/share/Xamarin/zips/F16A3455987DBAE5783F058F19F7FCDF.zip"
with a dummy `.zip` archive that doesn't contain any of the correct
files.

> error XA5217: Expected file
> /Users/macuser/.local/share/Xamarin/Xamarin.Android.Support.v4/23.4.0.0/content/m2repository/com/android/support/support-v4/23.4.0/support-v4-23.4.0.aar
> does not exist after extracting
> /Users/macuser/.local/share/Xamarin/zips/F16A3455987DBAE5783F058F19F7FCDF.zip

Results when a custom attribute contains a PackageName but no SourceUrl or InstallInstructions
----------------------------------------------------------------------------------------------

For example, remove the Xamarin.Android.Support.v4 package and add a
reference to a blank Xamarin.Android library project that includes the
following lines in the `AssemblyInfo.cs` file:

[assembly: Java.Interop.JavaLibraryReference ("foo.jar",
    PackageName     = "Foo",
    Version         = "0.0.0.0")]

> error XA5207: Unable to restore Java resources for package 'Foo'. The
> authors of the package should set the SourceUrl property or
> InstallInstructions property on the
> Java.Interop.JavaLibraryReferenceAttribute. (Details: Java library
> file foo.jar doesn't exist.)
@brendanzagaeski
Copy link
Owner Author

This was just to test something about the GitHub pull request interface.

brendanzagaeski pushed a commit that referenced this pull request Aug 16, 2018
Fixes: dotnet#1296

Xamarin.Android attempts to expose the Java-based Android API as a
".NET feeling" API. This takes many forms, such as prefixing interface
names with `I`, mapping `get` and `set` methods to properties, mapping
listener interfaces to events, and PascalCasing method names.

This also affects Java package names and C# namespaces.

When creating the `.apk` file, we philosophically need to go the
opposite direction: PascalCased members need to be mapped to
"something appropriate" within Java. For example, many Android
Resource ids *must* be all lowercase, and Android doesn't support
package names starting with an uppercase letter in all circumstances.

At one point, we tried mapping C# PascalCased namespaces to camelCased
namespaces, so e.g. `MyExampleNamespace` became the
`myExampleNamesapce` Java package within Java Callable Wrappers.

This turned out to be a Terrible Mistake, particularly on
case-sensitive filesystems, as if casing was *inconsistent*
(`MyExampleNamespace` vs `MyExamplenamespace`), files might not be
packaged.

By Mono for Android 1.0, we settled on just lowercasing the namespace
name to produce Java package names within Android Callable Wrappers.

This was not without it's own problems; in particular, the assembly
name wasn't involved, so if the "same" type (namespace + type) were
present in two different assemblies and we needed to generate Android
Callable Wrappers, they'd "collide," the build would fail, and we'd
have some unhappy customers.

This was later addressed in Xamarin.Android 5.1 by changing the Java
package name generation algorithm to be an MD5SUM of the assembly name
and namespace name, thus allowing types to have assembly identity.
(This was not without its own problems.)

Then it gets slightly more complicated: Android allows type names to
appear in various locations, such as in layout View XML. These don't
allow "just" using the type name; the package name is required for
types outside the `android.widget` Java package.

Initially, we did nothing, so developers had to directly use the
Android Callable Wrapper names:

	<myexamplenamespace.MyCustomCSharpView android:id="@+id/yay_csharp" .../>
	<fragment android:name="myexamplenamespace.MyCustomCSharpFragment" ... />

With the change in Xamarin.Android 5.1, *this couldn't work*; those
types didn't exist anymore.

To square this circle, we processed the resource files to "fixup"
identifiers and replace them with the actual Android Callable Wrapper
names. We'd replace any/all of:

	MyExampleNamespace.MyCustomCSharpView                           // Full name
	MyExampleNamespace.MyCustomCSharpView, MyAssembly               // Partial assembly-qualified name
	MyExampleNamespace.MyCustomCSharpView, MyAssembly, Version=...  // Full assembly qualified name
	myexamplenamespace.MyCustomCSharpView                           // compatibility name

with the appropriate md5'd Android Callable Wrapper name.

Brilliant as this was, there was a problem: [Bug #61073][61073].
If the assembly had a wildcard in the assembly version:

[61073]: https://bugzilla.xamarin.com/show_bug.cgi?id=61073

	[assembly: AssemblyVersion ("1.0.0.*")]

then the "Full assembly qualified name" value would change on *every
build*, which had numerious unintended knock-on effects.

This was fixed in commit e5b1c92, which worked largely by just
killing the Full assembly qualified name version entirely.
Xamarin.Android doesn't support embedding two different versions of
the same assembly, so this was considered to be fine.

...except for one compatibility case: `<fragment/>`s can contain
~arbitrary strings, and we support replacing the entire Full assembly
qualified name within them:

	<fragment
	    android:name="MyExampleNamespace.MyCustomCSharpFragment, MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
			...
	/>

However, in a post e5b1c92 world, the above now fails to load on the
device, because it's *not* being appropriately fixed up!

	FATAL EXCEPTION: main
	Process: Mono.Samples.HelloTests, PID: 22977
	java.lang.RuntimeException: Unable to start activity ComponentInfo{Mono.Samples.HelloTests/mono.samples.HelloApp}: android.view.InflateException: Binary XML file line #1: Binary XML file line #1: Error inflating class fragment
		...
	Caused by: android.view.InflateException: Binary XML file line #1: Binary XML file line #1: Error inflating class fragment
	Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class fragment
	Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment Mono.Samples.Hello.MyFragment, Hello, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: make sure class name exists, is public, and has an empty constructor that is public
		...
	Caused by: java.lang.ClassNotFoundException: Didn't find class "Mono.Samples.Hello.MyFragment, Hello, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" on path: DexPathList[[zip file "/data/app/Mono.Samples.HelloTests-1/base.apk"],nativeLibraryDirectories=[/data/app/Mono.Samples.HelloTests-1/lib/arm64, /system/fake-libs64, /data/app/Mono.Samples.HelloTests-1/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
		...

The problem is that what Android "sees" *should* be

	<fragment
	    android:name="md5whatever.MyCustomCSharpFragment"
			...
	/>

where `md5whatever.MyCustomCSharpFragment` *is* a valid Java type that
Android is able to load successfully, but because of e5b1c92 this
replacement was removed.

The fix: simplify the Full assembly-qualified name case to an already
supported example. If the `//fragment/@android:name` value contains a
`,`, assume it's an assembly qualified name and compute the Full name
from it, by stripping off the comma and everything after it, then use
the Full name to lookup the correct Android Callable Wrapper type.
brendanzagaeski pushed a commit that referenced this pull request Aug 16, 2018
Xamarin.Android uses the [ILRepack task][0] to repack/merge the
`Xamarin.Android.Build.Tasks.dll` assembly (610ade7), a step that is
performed after the `Xamarin.Android.Build.Tasks.csproj` project's
`Build` target completes.  The step takes the project's output
assembly -- `Xamarin.Android.Build.Tasks.dll` -- and several other
dependencies, then merges them into one, *replacing* the original
output assembly.

The majority of time it works flawlessly, however when building the
`monodroid` repo we observe a Mono runtime crash, similar-but-not-
identical to [mono issue 9613][m9613].  Not all details are
understood, but the high level overview of the issue is as follows:
Mono runtime uses the **mmap**(2) system call on Unix to map the
on-disk image of the assembly into memory.  The `mmapp`ed area is
used whenever the same assembly is loaded (e.g.
`Assembly.LoadFrom()`) into the application to save time and memory.
The memory is mapped as private which means that anything written to
the mapped area by the Mono process is effectively discarded, that is
not reflected in the file on disk.  The protection, however, doesn't
work in the other direction: when an external process (or even the
same Mono process!) writes to the file that was `mmapp`ed.
Unfortunately, the OS kernel behavior in such instance is left
undefined by the POSIX standard: the kernel can choose to reflect the
on-disk change in the mapping or ignore it.  On macOS the write is
ignored; on Linux, the write leads either to the `SIGBUS` signal
being sent to the process or corruption to the `mmap`ped memory area
(details of how this happens are, as of yet, unknown; it's just a
theory at this point).  The problem occurs in our case when the
`<ILRepacker/>` task overwrites the `Xamarin.Android.Build.Tasks.dll`
assembly with its merged/repackaged form and that, somehow, corrupts
Mono runtime's memory mapping of that assembly, eventually crashing:

        ## native crash
        #0  0x00007f974fd1b23a in __waitpid (pid=pid@entry=120561, stat_loc=stat_loc@entry=0x7f9712162b9c, options=options@entry=0) at ../sysdeps/unix/sysv/linux/waitpid.c:30
        #1  0x000055b471f36c96 in dump_native_stacktrace (ctx=0x7f97121637c0, signal=0x55b472147cd3 "SIGSEGV") at mini-posix.c:719
        dotnet#2  0x000055b471f36df2 in mono_dump_native_crash_info (signal=signal@entry=0x55b472147cd3 "SIGSEGV", ctx=ctx@entry=0x7f97121637c0, info=info@entry=0x7f97121638f0) at mini-posix.c:742
        dotnet#3  0x000055b471ecc620 in mono_handle_native_crash (signal=signal@entry=0x55b472147cd3 "SIGSEGV", ctx=ctx@entry=0x7f97121637c0, info=info@entry=0x7f97121638f0) at mini-exceptions.c:2938
        dotnet#4  0x000055b471e4c82c in mono_sigsegv_signal_handler (_dummy=7, _info=0x7f97121638f0, context=0x7f97121637c0) at mini-runtime.c:3441
        dotnet#5  <signal handler called>
        dotnet#6  __strcasecmp_l_avx () at ../sysdeps/x86_64/multiarch/strcmp-sse42.S:199
        dotnet#7  0x000055b471fb2105 in mono_assembly_names_equal_flags (l=l@entry=0x7f96e0004370, r=r@entry=0x7f97307edb60, flags=flags@entry=MONO_ANAME_EQ_IGNORE_CASE) at assembly.c:663
        dotnet#8  0x000055b471fa7baf in mono_domain_assembly_search (aname=0x7f96e0004370, user_data=0x0) at appdomain.c:2242
        dotnet#9  0x000055b471fb10f7 in mono_assembly_invoke_search_hook_internal (aname=aname@entry=0x7f96e0004370, requesting=requesting@entry=0x0, refonly=0, postload=postload@entry=0) at assembly.c:1755
        dotnet#10 0x000055b471fb4526 in mono_assembly_load_from_predicate (image=image@entry=0x7f96e001aae0, fname=fname@entry=0x7f96e000bc50 "/home/grendel/vc/xamarin/monodroid/monodroid/external/xamarin-android/src/Xamarin.Android.Build.Tasks/../../packages/ILRepack.Lib.MSBuild.Task.2.0.15.4/build/ILRepack.Lib.MSBuild.Task.dll", asmctx=asmctx@entry=MONO_ASMCTX_LOADFROM, predicate=predicate@entry=0x0, user_data=user_data@entry=0x0, status=status@entry=0x7f9712163fd4) at assembly.c:2638
        dotnet#11 0x000055b471fb635c in mono_assembly_open_predicate (filename=<optimized out>, filename@entry=0x7f96e000ae40 "/home/grendel/vc/xamarin/monodroid/monodroid/external/xamarin-android/src/Xamarin.Android.Build.Tasks/../../packages/ILRepack.Lib.MSBuild.Task.2.0.15.4/build/ILRepack.Lib.MSBuild.Task.dll", asmctx=MONO_ASMCTX_LOADFROM, predicate=predicate@entry=0x0, user_data=user_data@entry=0x0, status=status@entry=0x7f9712163fd4) at assembly.c:2206
        dotnet#12 0x000055b471fabd42 in ves_icall_System_Reflection_Assembly_LoadFrom (fname=..., refOnly=<optimized out>, error=0x7f9712164050) at appdomain.c:2272
        ...

        ## managed stacktrace
        at <unknown> <0xffffffff>
        at (wrapper managed-to-native) System.Reflection.Assembly.LoadFrom (string,bool) [0x0001b] in <79002cfb0e6e431d8465d6dcea08995e>:0
        at System.Reflection.Assembly.LoadFrom (string) [0x00000] in /home/grendel/vc/mono/mono/mcs/class/corlib/System.Reflection/Assembly.cs:539
        at System.Reflection.Assembly.UnsafeLoadFrom (string) [0x00000] in /home/grendel/vc/mono/mono/mcs/class/corlib/System.Reflection/Assembly.cs:571
        at Microsoft.Build.Shared.TypeLoader.LoadAssembly (Microsoft.Build.Shared.AssemblyLoadInfo) [0x0001e] in <bdc5207a22bb42ae9fe3f3d07e82871e>:0
        ...

The crash occurs in frame 7, because the `r` parameter (an instance
of the `MonoAssembly` structure) contains pointers that used to point
to valid places in the `Xamarin.Android.Build.Tasks.dll`s `mmap`ed
area, but now point to garbage data.  One of those corrupted pointers
is the ASCII assembly name - which is used by the function in frame 7.

The crash this commit fixes occurs in a very specific scenario: when
building the `OpenTK.csproj` project *directly*
(e.g. `msbuild OpenTK.csproj`), which causes the
`Xamarin.Android.Build.Tasks.dll` assembly to be loaded for use in
the `<UsingTask/>` MSBuild statement, but at the same time 
`OpenTK.csproj` has a `@(ProjectReference)` to
`Xamarin.Android.Build.Tasks.csproj`, which caused the
`<ILRepacker/>` task to run unconditionally, attempting to repack the
assemblies again and leading to the crash described above.

The fix, courtesy of @jonpryor, is to make the `ILRepacker` target
not run every time but only whenever the assembly has to be re-packed
because it has just been rebuilt.

This also improves rebuild times.

[0]: https://www.nuget.org/packages/ILRepack.Lib.MSBuild.Task
[m9613]: mono/mono#9613
brendanzagaeski pushed a commit that referenced this pull request Aug 16, 2018
…e fixed up. (dotnet#1720)

Context: dotnet#1711

When using a custom view within a layout file we replace the
`namespace.classname` with an `md5hash.classname`.  We do this by
using the `acwmap.txt` file to map known types onto the `md5` hashed
ones.  This is done in a case sensitive manner.  We also only support
identically-cased and lower-cased namespace/package names:

	ClassLibrary1.CustomView=md5d6f7135293df7527c983d45d07471c5e.CustomTextView
	classlibrary1.CustomView=md5d6f7135293df7527c983d45d07471c5e.CustomTextView

Given that a user is able to type these manually it is possible that
typo's will occur.  If for example a user types

	Classlibrary1.CustomView

this will NOT be fixed up, due to the lowercase `l` in `library`.
Instead the user will see the following error at runtime.

	FATAL UNHANDLED EXCEPTION: Android.Views.InflateException: Binary XML file line #1: Binary XML file line #1: Error inflating class Classlibrary1.CustomTextView
	---> Android.Views.InflateException: Binary XML file line #1: Error inflating class Classlibrary1.CustomTextView
	---> Java.Lang.ClassNotFoundException: Didn't find class "Classlibrary1.CustomTextView"

If the control is used in a number of places this runtime error does
nothing to help track down the problem.

Improve this scenario by detecting these issues and emitting an
XA1002 build error.  This will not only inform the user about the
problem but also provide a link to the file causing the problem.
brendanzagaeski pushed a commit that referenced this pull request Sep 26, 2018
…2199)

Fixes: dotnet#2193

I have been able to reproduce a #deletebinobj bug with the following
steps:
1. `File | New Project | Android App (Xamarin) | Tabbed App`, set
   `Minimum Android Version` to `Android 5.0 (Lollipop)`
2. Build
3. Add a new `TextView` to `Resources\layout\activity_main.axml`, with
   an id of `textView1`
4. Build and Deploy

Get a crash at runtime:

    Android.Views.InflateException: Binary XML file line #1: Error inflating class android.support.design.widget.BottomNavigationView occurred

A `Rebuild` fixes the problem, and the app starts correctly again.

After comparing `obj` directories from before and after, I noticed
`obj\Debug\android\src\android\support\compat\R.java` was missing the
field for `R.id.textView1`!

    public static int textView1=0x7f080091;

This doesn't match the error message we are getting here at all... But
this file is updated by the `_GenerateJavaDesignerForComponent`
MSBuild target. Further research showed that this target was getting
skipped at step no. 4 above, because it was found to be up to date
according to its inputs and outputs.

To verify this was the case, I could delete
`obj\Debug\Component.R.cs.flag` which would also resolve the runtime
exception (instead of a full `Rebuild`).

First, I created a new test:
- `CustomViewAddResourceId` builds a project with
  `<android.support.design.widget.BottomNavigationView />`
- Adds a `textView1` layout, builds again
- Verifies that `obj\Debug\android\src\android\support\compat\R.java`
  contains `textView1`

To fix the problem, I did the following:
- Added `$(_AndroidResgenFlagFile)` as an input to
  `_GenerateJavaDesignerForComponent`, so it will run again when
  `_UpdateAndroidResgen` runs
- Removed
  `AndroidComponentResgenFlagFile="$(_AndroidComponentResgenFlagFile)"`
  from the call to the `<Aapt />` MSBuild task, so it will re-run
  `aapt` and generate `R.java`.

However, things were breaking when `$(AndroidUseAapt2)` was
enabled.

For `aapt2` support I had to:
- Remove `AndroidComponentResgenFlagFile` from the `<Aapt2Link />`
  call
- Set an extra property that the other `<Aapt2Link />` calls are
  already doing:
  `CompiledResourceFlatArchive="$(IntermediateOutputPath)\compiled.flata"`
brendanzagaeski pushed a commit that referenced this pull request Feb 7, 2019
When using fastdev typemaps files we get the following error:

	F libc    : Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 5802 (haredandroidios), pid 5802 (haredandroidios)
	I crash_dump32: obtaining output fd from tombstoned, type: kDebuggerdTombstone
	I /system/bin/tombstoned: received crash request for pid 5802
	I crash_dump32: performing dump of process 5802 (target tid = 5802)
	F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
	F DEBUG   : Build fingerprint: 'Android/sdk_phone_x86/generic_x86:9/PSR1.180720.012/4923214:userdebug/test-keys'
	F DEBUG   : Revision: '0'
	F DEBUG   : ABI: 'x86'
	F DEBUG   : pid: 5802, tid: 5802, name: haredandroidios  >>> com.xamarin.blankformssharedandroidios <<<
	F DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
	F DEBUG   : Cause: null pointer dereference
	F DEBUG   :     eax 00000000  ebx e6b2e754  ecx 00000000  edx 00000000
	F DEBUG   :     edi e0cc58f0  esi 00000000
	F DEBUG   :     ebp ffd85ff8  esp ffd85fcc  eip e6a60532
	F DEBUG   :
	F DEBUG   : backtrace:
	F DEBUG   :     #00 pc 0001e532  /system/lib/libc.so (strlen+18)
	F DEBUG   :     #1 pc 00075952  /system/lib/libc.so (strdup+34)
	F DEBUG   :     dotnet#2 pc 0000f6ab  /data/app/com.xamarin.blankformssharedandroidios-nCq7hL5Bz-TYILJl3W97zw==/lib/x86/libmonodroid.so (xamarin::android::internal::EmbeddedAssemblies::add_type_mapping(xamarin::android::internal::TypeMappingInfo**, char const*, char const*, char const*)+667)
	F DEBUG   :     dotnet#3 pc 00010ed7  /data/app/com.xamarin.blankformssharedandroidios-nCq7hL5Bz-TYILJl3W97zw==/lib/x86/libmonodroid.so (xamarin::android::internal::EmbeddedAssemblies::try_load_typemaps_from_directory(char const*)+871)
	F DEBUG   :     dotnet#4 pc 000233b8  /data/app/com.xamarin.blankformssharedandroidios-nCq7hL5Bz-TYILJl3W97zw==/lib/x86/libmonodroid.so (gather_bundled_assemblies(_JNIEnv*, xamarin::android::jstring_array_wrapper&, bool, int*)+248)
	F DEBUG   :     dotnet#5 pc 000229c6  /data/app/com.xamarin.blankformssharedandroidios-nCq7hL5Bz-TYILJl3W97zw==/lib/x86/libmonodroid.so (create_domain(_JNIEnv*, _jclass*, xamarin::android::jstring_array_wrapper&, _jstring*, _jobject*, bool)+166)
	F DEBUG   :     dotnet#6 pc 0001f20c  /data/app/com.xamarin.blankformssharedandroidios-nCq7hL5Bz-TYILJl3W97zw==/lib/x86/libmonodroid.so (create_and_initialize_domain(_JNIEnv*, _jclass*, xamarin::android::jstring_array_wrapper&, _jobjectArray*, _jobject*, bool)+204)
	F DEBUG   :     dotnet#7 pc 0001c7af  /data/app/com.xamarin.blankformssharedandroidios-nCq7hL5Bz-TYILJl3W97zw==/lib/x86/libmonodroid.so (Java_mono_android_Runtime_init+4255)


The was down to the `try_load_typemaps_from_directory()` passing a
`nullptr` to the `add_type_mapping()` method.  This method was
calling **strdup**(3), which does NOT like `nullptr`.

Since the `source_entry` argument is only used for logging we might
as well create a constant string with a value of `.__override__` so
that if there is a problem we can see from the logs this was a
fastdev issue.
brendanzagaeski pushed a commit that referenced this pull request Mar 4, 2019
Currently when running the `Mono.Android-Test` app we get the
following error:

	Java.Lang.RuntimeException: Binary XML file line #1: You must supply a layout_width attribute.

This is because `ScrollView` now needs to have the properties
`//@android:layout_width` and `//@android:layout_height`.  Once we
provide those, we then get:

	Scrollview can host only one direct child

We then need to add a `LinearLayout` to the `ScrollView` so that it
removes that error as well.
brendanzagaeski pushed a commit that referenced this pull request Mar 4, 2019
…t#2735)

Fixes: dotnet#2684

Context: https://www.guardsquare.com/en/products/proguard/manual/usage#keepoptionmodifiers
Context: https://www.guardsquare.com/en/products/proguard/manual/examples

Using R8 on a pre-Android 8.0 device was crashing with:

	Unhandled Exception:
	Java.Lang.LinkageError: no non-static method "Landroid/runtime/UncaughtExceptionHandler;.<init>()V"
	  at Java.Interop.JniEnvironment+InstanceMethods.GetMethodID (Java.Interop.JniObjectReference type, System.String name, System.String signature) [0x0005b] in <7d7bcc9ee9cc460db8abcdb9a9622733>:0
	  at Java.Interop.JniType.GetConstructor (System.String signature) [0x0000c] in <7d7bcc9ee9cc460db8abcdb9a9622733>:0
	  at Java.Interop.JniPeerMembers+JniInstanceMethods.GetConstructor (System.String signature) [0x00035] in <7d7bcc9ee9cc460db8abcdb9a9622733>:0
	  at Java.Interop.JniPeerMembers+JniInstanceMethods.FinishCreateInstance (System.String constructorSignature, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00036] in <7d7bcc9ee9cc460db8abcdb9a9622733>:0
	  at Java.Lang.Object..ctor () [0x00054] in <d77389624c8c4948a12589c4bd4500eb>:0
	  at Android.Runtime.UncaughtExceptionHandler..ctor (Java.Lang.Thread+IUncaughtExceptionHandler defaultHandler) [0x00000] in <d77389624c8c4948a12589c4bd4500eb>:0
	  at Android.Runtime.JNIEnv.Initialize (Android.Runtime.JnienvInitializeArgs* args) [0x00202] in <d77389624c8c4948a12589c4bd4500eb>:0
	  --- End of managed Java.Lang.LinkageError stack trace ---
	java.lang.NoSuchMethodError: no non-static method "Landroid/runtime/UncaughtExceptionHandler;.<init>()V"
	  at mono.android.Runtime.init(Native Method)
	  at mono.MonoPackageManager.LoadApplication(:21)
	  at mono.MonoRuntimeProvider.attachInfo(:1)
	  at android.app.ActivityThread.installProvider(ActivityThread.java:5853)
	  at android.app.ActivityThread.installContentProviders(ActivityThread.java:5445)
	  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5384)
	  at android.app.ActivityThread.-wrap2(ActivityThread.java)
	  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1545)
	  at android.os.Handler.dispatchMessage(Handler.java:102)
	  at android.os.Looper.loop(Looper.java:154)
	  at android.app.ActivityThread.main(ActivityThread.java:6119)
	  at java.lang.reflect.Method.invoke(Native Method)
	  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
	  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

Looking into it, the following method was present when using
ProGuard, but not R8:

	#1              : (in Landroid/runtime/UncaughtExceptionHandler;)
	  name          : '<init>'
	  type          : '()V'
	  access        : 0x10001 (PUBLIC CONSTRUCTOR)
	  code          -
	  registers     : 4
	  ins           : 1
	  outs          : 4
	  insns size    : 22 16-bit code units
	  catches       : (none)
	  positions     :
	    0x0000 line=22
	    0x0003 line=23
	    0x0010 line=24
	  locals        :
	    0x0000 - 0x0016 reg=3 this Landroid/runtime/UncaughtExceptionHandler;

I looked at `proguard_xamarin.cfg`, and noticed something strange:

	-keep class android.runtime.** { <init>(***); }

It seemed this rule was being ignored?  All the other *working* rules
were using `<init>(...);` to refer to the instance constructor.

I reviewed [ProGuard's documented syntax/grammar][0]:

	[@annotationtype] [[!]public|final|abstract|@ ...] [!]interface|class|enum classname
	    [extends|implements [@annotationtype] classname]
	[{
	    [@annotationtype] [[!]public|private|protected|static|volatile|transient ...]
	        <fields> |
	        (fieldtype fieldname);
	    [@annotationtype] [[!]public|private|protected|static|synchronized|native|abstract|strictfp ...]
	        <methods> |
	        <init>(argumenttype,...) |
	        classname(argumenttype,...) |
	        (returntype methodname(argumenttype,...));
	    [@annotationtype] [[!]public|private|protected|static ... ] *;
	    ...
	}]

It seems `(...)` is the proper way to specify a match against any set
of arguments.  Looking through ProGuard's examples, I can't find any
usage of `(***)`.  It must *happened* to work, but is undocumented.

R8 does not appear to accept the `(***)` syntax at all.

Update `proguard_xamarin.cfg` so that it uses `(...)`, not `(***)`,
allowing R8 to properly process `proguard_xamarin.cfg`.

~~ Other changes ~~

I expanded upon the `DexUtils` class so it can look for methods within
classes. I also adjusted one test to verify this problem is solved.

[0]: https://www.guardsquare.com/en/products/proguard/manual/usage#classspecification
brendanzagaeski pushed a commit that referenced this pull request Jun 18, 2019
…t#3218)

Fixes: dotnet#3123

Scenario:

 1. Create a Solution in which the `App.csproj` references a
    `MonoAndroid`-profile `Library.csproj` project.
 2. `Library.csproj` contains an `Android.Views.View` subclass.
 3. `Library.csproj` contains an `@(AndroidResource)` with a layout
    `.axml` file which uses the `View` from (2)
 4. `App` project uses (2) with `Activity.SetContentView()`.
 5. Build & Run the project; it works.
 6. Update the `View` subclass from (2).
 7. Build & run the project.    

Step (7) is expected to result in a successful app launch.  Instead,
it fails during process startup:

	Android.Views.InflateException: Binary XML file line #1: Binary XML file line #1: Error inflating class InflatedLibrary.CodeBehindClass occurred

Commit 373c6ed added a new `_ConvertCustomView` target to handle the
conversion of custom view to the md5 hash versions.  While it worked
*most* of the time, there was a very specific area where it was not
fixing up the custom views.

This problem only occurs when a library project code is updated, as
with step (6).  When happens next is that when the main app builds
and the library resources are then re-extracted into the
`$(IntermediateOutputPath)lp\XX\ji\res` directory.
The `<ConvertResorucesCases/>` task is then run to fixup those `res`
files with the correct casing.  Then the `<GenerateJavaStubs/>` task
is run, because the library project was updated.

However at this point the wheels fall of the wagon because the
`_ConvertCustomViews` target does NOT run.  This is because it is
only using the following inputs:

	$(_CustomViewMapFile);$(_AcwMapFile)

Neither of these files are updated in this instance.  `$(_AcwMapFile)`
will only be updated if a class or namespace are changed.  If code
within a class is changed in a way which doesn't alter the class or
namespace name, then nothing in the ACW map will need to be updated,
so we don't update the file.

The `$(_CustomViewMapFile)` is also not updated, unless resources are
added or removed.  So that doesn't change either.  The result is the
target is skipped, and we end up with a custom view which does NOT
have the correct type names.  This results in the above error.

The fix in this case is to update the Inputs of the
`_ConvertCustomView` target to have the following

	$(_CustomViewMapFile);$(_AcwMapFile);@(_AndroidResourceDest);@(_LibraryResourceDirectoryStamps)

By including these two extra items we can make sure the target runs
if either an app resource is updated or if a library project changes.

A unit test has been updated to test for this particular issue.
brendanzagaeski pushed a commit that referenced this pull request Apr 9, 2020
Context: https://github.com/jfversluis/SwipeViewDemo
Context: https://github.com/xamarin/Xamarin.Forms/blob/fa33ca3b3ac5c7c875023db785b56c67015e13b1/Xamarin.Forms.Platform.Android/AppCompat/TabbedPageRenderer.cs#L512

Commit 7117414 introduced native code which queries the Mono runtime
to obtain an instance of a `MonoClass` for a given `MonoReflectionType`
as well as the `MonoImage` associated with the `MonoClass`:

	// EmbeddedAssemblies::typemap_managed_to_java(MonoReflectionType *reflection_type, const uint8_t *mvid)
	MonoReflectionType     *reflection_type = …
	MonoType               *type            = mono_reflection_type_get_type (reflection_type);
	MonoClass              *klass           = mono_type_get_class (type);   // PROBLEMATIC
	// EmbeddedAssemblies::typemap_managed_to_java(MonoType *type, MonoClass *klass, const uint8_t *mvid)
	MonoImage              *image           = mono_class_get_image (klass);

However, it appears that when dealing with closed generic types -- such
as with `new GenericHolder<int>()` -- the above call chain results in a
SIGSEGV instead of a valid `MonoImage*`:

	F libc    : Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x3000021 in tid 19030 (s.swipeviewdemo), pid 19030 (s.swipeviewdemo)
	I crash_dump32: obtaining output fd from tombstoned, type: kDebuggerdTombstone
	I /system/bin/tombstoned: received crash request for pid 19030
	I crash_dump32: performing dump of process 19030 (target tid = 19030)
	F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
	F DEBUG   : Build fingerprint: 'google/sdk_gphone_x86/generic_x86:10/QSR1.191030.002/5978551:userdebug/dev-keys'
	F DEBUG   : Revision: '0'
	F DEBUG   : ABI: 'x86'
	F DEBUG   : Timestamp: 2020-04-08 15:52:55+0200
	F DEBUG   : pid: 19030, tid: 19030, name: s.swipeviewdemo  >>> nl.versluis.swipeviewdemo <<<
	F DEBUG   : uid: 10135
	F DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x3000021
	F DEBUG   :     eax 03000005  ebx cb9f4d24  ecx 7191c13b  edx 00000004
	F DEBUG   :     edi 03000005  esi ffb22080
	F DEBUG   :     ebp ffb22108  esp ffb2206c  eip cbcfc1e4
	F DEBUG   :
	F DEBUG   : backtrace:
	F DEBUG   :       #00 pc 001b41e4  /data/app/Mono.Android.DebugRuntime-umHhDz421s4-tshrHwha0w==/lib/x86/libmonosgen-32bit-2.0.so (mono_image_get_name+4)
	F DEBUG   :       #1 pc 0000cac7  /data/app/nl.versluis.swipeviewdemo-jCFH_bcCNuFx1tLUhaJ4nw==/lib/x86/libmonodroid.so (xamarin::android::internal::EmbeddedAssemblies::typemap_managed_to_java(_MonoType*, _MonoClass*, unsigned char const*)+263) (BuildId: a2585ad379f788049e463af58c8686e9cdc1e778)
	F DEBUG   :       dotnet#2 pc 0000c8cc  /data/app/nl.versluis.swipeviewdemo-jCFH_bcCNuFx1tLUhaJ4nw==/lib/x86/libmonodroid.so (xamarin::android::internal::EmbeddedAssemblies::typemap_managed_to_java(_MonoReflectionType*, unsigned char const*)+124) (BuildId: a2585ad379f788049e463af58c8686e9cdc1e778)
	F DEBUG   :       dotnet#3 pc 0001621a  /data/app/nl.versluis.swipeviewdemo-jCFH_bcCNuFx1tLUhaJ4nw==/lib/x86/libmonodroid.so (xamarin::android::internal::MonodroidRuntime::typemap_managed_to_java(_MonoReflectionType*, unsigned char const*)+42) (BuildId: a2585ad379f788049e463af58c8686e9cdc1e778)
	F DEBUG   :       dotnet#4 pc 000325af  <anonymous:c7858000>

Investigating the issue I discovered that one of two things happened:

 1. the returned `MonoImage` instance was invalid, *or*
 2. the instance was valid but image name stored in `MonoImage`
    was `null`

(1) would only happen in 32-bit builds, resulting in a SIGSEGV within
`mono_image_get_name()`, because the `image` pointer value of 0x3000005
was invalid:

	I monodroid: const char *xamarin::android::internal::EmbeddedAssemblies::typemap_managed_to_java(MonoType *, MonoClass *, const uint8_t *)
	I monodroid:   type == 0xc6e60d3c, klass == 0xc6e60cb8, mvid == 0xc8c02d90
	I monodroid:   type name == Xamarin.Forms.Platform.Android.AppCompat.FormsFragmentPagerAdapter`1[Xamarin.Forms.Page]
	I monodroid:   calling mono_class_get_image (0xc6e60cb8)
	I monodroid:     image == 0x3000005

(2) only happened in 64-bit builds, resulting in a SIGSEGV as
`strlen()` was passed a `null` pointer:

	I monodroid: const char *xamarin::android::internal::EmbeddedAssemblies::typemap_managed_to_java(MonoType *, MonoClass *, const uint8_t *)
	I monodroid:   type == 0x7ce3fecc78, klass == 0x7ce3fecb98, mvid == 0x7ce9404520
	I monodroid:   type name == Xamarin.Forms.Platform.Android.AppCompat.FormsFragmentPagerAdapter`1[Xamarin.Forms.Page]
	I monodroid:   calling mono_class_get_image (0x7ce3fecb98)
	I monodroid:     image == 0x7ce3fecbc8
	I monodroid:     image_name == <null>

I found out that the root cause was in the `mono_type_get_class()` call
which is supposed to be used with great caution as it eventually calls
the `mono_type_get_class_internal()` function which is supposed to be
called only for object types `MONO_TYPE_CLASS` and `MONO_TYPE_VALUETYPE`
but not `MONO_TYPE_GENERICINST`, and `MONO_TYPE_GENERICINST` is used
for closed generic types.

The fix is to call the `mono_class_from_mono_type()` function instead
which, albeit slower, is safer and works correctly in all cases:

	// EmbeddedAssemblies::typemap_managed_to_java(MonoReflectionType *reflection_type, const uint8_t *mvid)
	MonoReflectionType     *reflection_type = …
	MonoType               *type            = mono_reflection_type_get_type (reflection_type);
	MonoClass              *klass           = mono_class_from_mono_type (type);     // PART OF THE FIX
	// EmbeddedAssemblies::typemap_managed_to_java(MonoType *type, MonoClass *klass, const uint8_t *mvid)
	MonoImage              *image           = mono_class_get_image (klass)

Fixing this led to the next issue, a managed exception thrown after the
runtime failed to map a managed type name to Java type name:

	W monodroid-assembly: typemap: unable to find mapping to a Java type from managed type 'Xamarin.Forms.Platform.Android.AppCompat.FormsFragmentPagerAdapter`1[T], Xamarin.Forms.Platform.Android'
	I monodroid-timing: Typemap.managed_to_java: end, total time; elapsed: 0s:0::33177
	D Mono    : DllImport attempting to load: '/system/lib64/liblog.so'.
	D Mono    : DllImport loaded library '/system/lib64/liblog.so'.
	D Mono    : DllImport searching in: '/system/lib64/liblog.so' ('/system/lib64/liblog.so').
	D Mono    : Searching for '__android_log_print'.
	D Mono    : Probing '__android_log_print'.
	D Mono    : Found as '__android_log_print'.
	I MonoDroid: UNHANDLED EXCEPTION:
	I MonoDroid: System.NotSupportedException: Cannot create instance of type 'Xamarin.Forms.Platform.Android.AppCompat.FormsFragmentPagerAdapter`1[[Xamarin.Forms.Page, Xamarin.Forms.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null]]': no Java peer type found.
	I MonoDroid:   at Java.Interop.JniPeerMembers+JniInstanceMethods..ctor (System.Type declaringType) [0x0004b] in <514e1249792e47a180b3f1293306b972>:0
	I MonoDroid:   at Java.Interop.JniPeerMembers+JniInstanceMethods.GetConstructorsForType (System.Type declaringType) [0x00031] in <514e1249792e47a180b3f1293306b972>:0
	I MonoDroid:   at Java.Interop.JniPeerMembers+JniInstanceMethods.StartCreateInstance (System.String constructorSignature, System.Type declaringType, Java.Interop.JniArgumentValue* parameters) [0x00038] in <514e1249792e47a180b3f1293306b972>:0
	I MonoDroid:   at Android.Support.V4.App.FragmentPagerAdapter..ctor (Android.Support.V4.App.FragmentManager fm) [0x0005b] in <fefee6c2c695459088a9df092723e052>:0
	I MonoDroid:   at Xamarin.Forms.Platform.Android.AppCompat.FormsFragmentPagerAdapter`1[T]..ctor (Xamarin.Forms.MultiPage`1[T] page, Android.Support.V4.App.FragmentManager fragmentManager) [0x00000] in <9d12bb15abb54c508c4bee636d1b3a42>:0
	I MonoDroid:   at Xamarin.Forms.Platform.Android.AppCompat.TabbedPageRenderer.CreateFormsViewPager (Android.Content.Context context, Xamarin.Forms.TabbedPage tabbedPage) [0x00033] in <9d12bb15abb54c508c4bee636d1b3a42>:0
	I MonoDroid:   at Xamarin.Forms.Platform.Android.AppCompat.TabbedPageRenderer.OnElementChanged (Xamarin.Forms.Platform.Android.ElementChangedEventArgs`1[TElement] e) [0x001cd] in <9d12bb15abb54c508c4bee636d1b3a42>:0
	I MonoDroid:   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x000c0] in <9d12bb15abb54c508c4bee636d1b3a42>:0
	I MonoDroid:   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00033] in <9d12bb15abb54c508c4bee636d1b3a42>:0
	I MonoDroid:   at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context) [0x0001f] in <9d12bb15abb54c508c4bee636d1b3a42>:0
	I MonoDroid:   at Xamarin.Forms.Platform.Android.AppCompat.Platform.AddChild (Xamarin.Forms.Page page, System.Boolean layout) [0x0000d] in <9d12bb15abb54c508c4bee636d1b3a42>:0
	I MonoDroid:   at Xamarin.Forms.Platform.Android.AppCompat.Platform.SetPageInternal (Xamarin.Forms.Page newRoot) [0x00061] in <9d12bb15abb54c508c4bee636d1b3a42>:0
	I MonoDroid:   at Xamarin.Forms.Platform.Android.AppCompat.Platform.SetPage (Xamarin.Forms.Page newRoot) [0x000e6] in <9d12bb15abb54c508c4bee636d1b3a42>:0
	I MonoDroid:   at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.InternalSetPage (Xamarin.Forms.Page page) [0x0003f] in <9d12bb15abb54c508c4bee636d1b3a42>:0
	I MonoDroid:   at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.SetMainPage () [0x0000c] in <9d12bb15abb54c508c4bee636d1b3a42>:0
	I MonoDroid:   at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.LoadApplication (Xamarin.Forms.Application application) [0x00140] in <9d12bb15abb54c508c4bee636d1b3a42>:0
	I MonoDroid:   at SwipeViewDemo.Droid.MainActivity.OnCreate (Android.OS.Bundle savedInstanceState) [0x00035] in <15e30af50bb64ff6b6d20ac6fd546763>:0
	I MonoDroid:   at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_savedInstanceState) [0x0000f] in <515e813169e54876823978ab785f569a>:0
	I MonoDroid:   at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.7(intptr,intptr,intptr)

Note that the type name as seen by the native code via
`mono_get_type_name_full()` is:

	Xamarin.Forms.Platform.Android.AppCompat.FormsFragmentPagerAdapter`1[T], Xamarin.Forms.Platform.Android

while `Mono.Android.dll` expects to be looking for:

	Xamarin.Forms.Platform.Android.AppCompat.FormsFragmentPagerAdapter`1, Xamarin.Forms.Platform.Android

This discrepancy was caused by calling `mono_get_type_name_full()`
with its format parameter set to `MONO_TYPE_NAME_FORMAT_REFLECTION`,
while we needed the format value of `MONO_TYPE_NAME_FORMAT_FULL_NAME`.
brendanzagaeski pushed a commit that referenced this pull request Apr 25, 2020
Context: https://github.com/jfversluis/SwipeViewDemo
Context: https://github.com/xamarin/Xamarin.Forms/blob/fa33ca3b3ac5c7c875023db785b56c67015e13b1/Xamarin.Forms.Platform.Android/AppCompat/TabbedPageRenderer.cs#L512

Commit 7117414 introduced native code which queries the Mono runtime
to obtain an instance of a `MonoClass` for a given `MonoReflectionType`
as well as the `MonoImage` associated with the `MonoClass`:

	// EmbeddedAssemblies::typemap_managed_to_java(MonoReflectionType *reflection_type, const uint8_t *mvid)
	MonoReflectionType     *reflection_type = …
	MonoType               *type            = mono_reflection_type_get_type (reflection_type);
	MonoClass              *klass           = mono_type_get_class (type);   // PROBLEMATIC
	// EmbeddedAssemblies::typemap_managed_to_java(MonoType *type, MonoClass *klass, const uint8_t *mvid)
	MonoImage              *image           = mono_class_get_image (klass);

However, it appears that when dealing with closed generic types -- such
as with `new GenericHolder<int>()` -- the above call chain results in a
SIGSEGV instead of a valid `MonoImage*`:

	F libc    : Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x3000021 in tid 19030 (s.swipeviewdemo), pid 19030 (s.swipeviewdemo)
	I crash_dump32: obtaining output fd from tombstoned, type: kDebuggerdTombstone
	I /system/bin/tombstoned: received crash request for pid 19030
	I crash_dump32: performing dump of process 19030 (target tid = 19030)
	F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
	F DEBUG   : Build fingerprint: 'google/sdk_gphone_x86/generic_x86:10/QSR1.191030.002/5978551:userdebug/dev-keys'
	F DEBUG   : Revision: '0'
	F DEBUG   : ABI: 'x86'
	F DEBUG   : Timestamp: 2020-04-08 15:52:55+0200
	F DEBUG   : pid: 19030, tid: 19030, name: s.swipeviewdemo  >>> nl.versluis.swipeviewdemo <<<
	F DEBUG   : uid: 10135
	F DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x3000021
	F DEBUG   :     eax 03000005  ebx cb9f4d24  ecx 7191c13b  edx 00000004
	F DEBUG   :     edi 03000005  esi ffb22080
	F DEBUG   :     ebp ffb22108  esp ffb2206c  eip cbcfc1e4
	F DEBUG   :
	F DEBUG   : backtrace:
	F DEBUG   :       #00 pc 001b41e4  /data/app/Mono.Android.DebugRuntime-umHhDz421s4-tshrHwha0w==/lib/x86/libmonosgen-32bit-2.0.so (mono_image_get_name+4)
	F DEBUG   :       #1 pc 0000cac7  /data/app/nl.versluis.swipeviewdemo-jCFH_bcCNuFx1tLUhaJ4nw==/lib/x86/libmonodroid.so (xamarin::android::internal::EmbeddedAssemblies::typemap_managed_to_java(_MonoType*, _MonoClass*, unsigned char const*)+263) (BuildId: a2585ad379f788049e463af58c8686e9cdc1e778)
	F DEBUG   :       dotnet#2 pc 0000c8cc  /data/app/nl.versluis.swipeviewdemo-jCFH_bcCNuFx1tLUhaJ4nw==/lib/x86/libmonodroid.so (xamarin::android::internal::EmbeddedAssemblies::typemap_managed_to_java(_MonoReflectionType*, unsigned char const*)+124) (BuildId: a2585ad379f788049e463af58c8686e9cdc1e778)
	F DEBUG   :       dotnet#3 pc 0001621a  /data/app/nl.versluis.swipeviewdemo-jCFH_bcCNuFx1tLUhaJ4nw==/lib/x86/libmonodroid.so (xamarin::android::internal::MonodroidRuntime::typemap_managed_to_java(_MonoReflectionType*, unsigned char const*)+42) (BuildId: a2585ad379f788049e463af58c8686e9cdc1e778)
	F DEBUG   :       dotnet#4 pc 000325af  <anonymous:c7858000>

Investigating the issue I discovered that one of two things happened:

 1. the returned `MonoImage` instance was invalid, *or*
 2. the instance was valid but image name stored in `MonoImage`
    was `null`

(1) would only happen in 32-bit builds, resulting in a SIGSEGV within
`mono_image_get_name()`, because the `image` pointer value of 0x3000005
was invalid:

	I monodroid: const char *xamarin::android::internal::EmbeddedAssemblies::typemap_managed_to_java(MonoType *, MonoClass *, const uint8_t *)
	I monodroid:   type == 0xc6e60d3c, klass == 0xc6e60cb8, mvid == 0xc8c02d90
	I monodroid:   type name == Xamarin.Forms.Platform.Android.AppCompat.FormsFragmentPagerAdapter`1[Xamarin.Forms.Page]
	I monodroid:   calling mono_class_get_image (0xc6e60cb8)
	I monodroid:     image == 0x3000005

(2) only happened in 64-bit builds, resulting in a SIGSEGV as
`strlen()` was passed a `null` pointer:

	I monodroid: const char *xamarin::android::internal::EmbeddedAssemblies::typemap_managed_to_java(MonoType *, MonoClass *, const uint8_t *)
	I monodroid:   type == 0x7ce3fecc78, klass == 0x7ce3fecb98, mvid == 0x7ce9404520
	I monodroid:   type name == Xamarin.Forms.Platform.Android.AppCompat.FormsFragmentPagerAdapter`1[Xamarin.Forms.Page]
	I monodroid:   calling mono_class_get_image (0x7ce3fecb98)
	I monodroid:     image == 0x7ce3fecbc8
	I monodroid:     image_name == <null>

I found out that the root cause was in the `mono_type_get_class()` call
which is supposed to be used with great caution as it eventually calls
the `mono_type_get_class_internal()` function which is supposed to be
called only for object types `MONO_TYPE_CLASS` and `MONO_TYPE_VALUETYPE`
but not `MONO_TYPE_GENERICINST`, and `MONO_TYPE_GENERICINST` is used
for closed generic types.

The fix is to call the `mono_class_from_mono_type()` function instead
which, albeit slower, is safer and works correctly in all cases:

	// EmbeddedAssemblies::typemap_managed_to_java(MonoReflectionType *reflection_type, const uint8_t *mvid)
	MonoReflectionType     *reflection_type = …
	MonoType               *type            = mono_reflection_type_get_type (reflection_type);
	MonoClass              *klass           = mono_class_from_mono_type (type);     // PART OF THE FIX
	// EmbeddedAssemblies::typemap_managed_to_java(MonoType *type, MonoClass *klass, const uint8_t *mvid)
	MonoImage              *image           = mono_class_get_image (klass)

Fixing this led to the next issue, a managed exception thrown after the
runtime failed to map a managed type name to Java type name:

	W monodroid-assembly: typemap: unable to find mapping to a Java type from managed type 'Xamarin.Forms.Platform.Android.AppCompat.FormsFragmentPagerAdapter`1[T], Xamarin.Forms.Platform.Android'
	I monodroid-timing: Typemap.managed_to_java: end, total time; elapsed: 0s:0::33177
	D Mono    : DllImport attempting to load: '/system/lib64/liblog.so'.
	D Mono    : DllImport loaded library '/system/lib64/liblog.so'.
	D Mono    : DllImport searching in: '/system/lib64/liblog.so' ('/system/lib64/liblog.so').
	D Mono    : Searching for '__android_log_print'.
	D Mono    : Probing '__android_log_print'.
	D Mono    : Found as '__android_log_print'.
	I MonoDroid: UNHANDLED EXCEPTION:
	I MonoDroid: System.NotSupportedException: Cannot create instance of type 'Xamarin.Forms.Platform.Android.AppCompat.FormsFragmentPagerAdapter`1[[Xamarin.Forms.Page, Xamarin.Forms.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null]]': no Java peer type found.
	I MonoDroid:   at Java.Interop.JniPeerMembers+JniInstanceMethods..ctor (System.Type declaringType) [0x0004b] in <514e1249792e47a180b3f1293306b972>:0
	I MonoDroid:   at Java.Interop.JniPeerMembers+JniInstanceMethods.GetConstructorsForType (System.Type declaringType) [0x00031] in <514e1249792e47a180b3f1293306b972>:0
	I MonoDroid:   at Java.Interop.JniPeerMembers+JniInstanceMethods.StartCreateInstance (System.String constructorSignature, System.Type declaringType, Java.Interop.JniArgumentValue* parameters) [0x00038] in <514e1249792e47a180b3f1293306b972>:0
	I MonoDroid:   at Android.Support.V4.App.FragmentPagerAdapter..ctor (Android.Support.V4.App.FragmentManager fm) [0x0005b] in <fefee6c2c695459088a9df092723e052>:0
	I MonoDroid:   at Xamarin.Forms.Platform.Android.AppCompat.FormsFragmentPagerAdapter`1[T]..ctor (Xamarin.Forms.MultiPage`1[T] page, Android.Support.V4.App.FragmentManager fragmentManager) [0x00000] in <9d12bb15abb54c508c4bee636d1b3a42>:0
	I MonoDroid:   at Xamarin.Forms.Platform.Android.AppCompat.TabbedPageRenderer.CreateFormsViewPager (Android.Content.Context context, Xamarin.Forms.TabbedPage tabbedPage) [0x00033] in <9d12bb15abb54c508c4bee636d1b3a42>:0
	I MonoDroid:   at Xamarin.Forms.Platform.Android.AppCompat.TabbedPageRenderer.OnElementChanged (Xamarin.Forms.Platform.Android.ElementChangedEventArgs`1[TElement] e) [0x001cd] in <9d12bb15abb54c508c4bee636d1b3a42>:0
	I MonoDroid:   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x000c0] in <9d12bb15abb54c508c4bee636d1b3a42>:0
	I MonoDroid:   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00033] in <9d12bb15abb54c508c4bee636d1b3a42>:0
	I MonoDroid:   at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context) [0x0001f] in <9d12bb15abb54c508c4bee636d1b3a42>:0
	I MonoDroid:   at Xamarin.Forms.Platform.Android.AppCompat.Platform.AddChild (Xamarin.Forms.Page page, System.Boolean layout) [0x0000d] in <9d12bb15abb54c508c4bee636d1b3a42>:0
	I MonoDroid:   at Xamarin.Forms.Platform.Android.AppCompat.Platform.SetPageInternal (Xamarin.Forms.Page newRoot) [0x00061] in <9d12bb15abb54c508c4bee636d1b3a42>:0
	I MonoDroid:   at Xamarin.Forms.Platform.Android.AppCompat.Platform.SetPage (Xamarin.Forms.Page newRoot) [0x000e6] in <9d12bb15abb54c508c4bee636d1b3a42>:0
	I MonoDroid:   at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.InternalSetPage (Xamarin.Forms.Page page) [0x0003f] in <9d12bb15abb54c508c4bee636d1b3a42>:0
	I MonoDroid:   at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.SetMainPage () [0x0000c] in <9d12bb15abb54c508c4bee636d1b3a42>:0
	I MonoDroid:   at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.LoadApplication (Xamarin.Forms.Application application) [0x00140] in <9d12bb15abb54c508c4bee636d1b3a42>:0
	I MonoDroid:   at SwipeViewDemo.Droid.MainActivity.OnCreate (Android.OS.Bundle savedInstanceState) [0x00035] in <15e30af50bb64ff6b6d20ac6fd546763>:0
	I MonoDroid:   at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_savedInstanceState) [0x0000f] in <515e813169e54876823978ab785f569a>:0
	I MonoDroid:   at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.7(intptr,intptr,intptr)

Note that the type name as seen by the native code via
`mono_get_type_name_full()` is:

	Xamarin.Forms.Platform.Android.AppCompat.FormsFragmentPagerAdapter`1[T], Xamarin.Forms.Platform.Android

while `Mono.Android.dll` expects to be looking for:

	Xamarin.Forms.Platform.Android.AppCompat.FormsFragmentPagerAdapter`1, Xamarin.Forms.Platform.Android

This discrepancy was caused by calling `mono_get_type_name_full()`
with its format parameter set to `MONO_TYPE_NAME_FORMAT_REFLECTION`,
while we needed the format value of `MONO_TYPE_NAME_FORMAT_FULL_NAME`.
brendanzagaeski pushed a commit that referenced this pull request May 12, 2020
…otnet#4673)

Fixes: dotnet#4596
Context: a017561
Context: https://gist.github.com/pjcollins/87762e81f1f3c7e8b821356e4612eecf

A missing parameter in a call to `log_debug` added iFixes: dotnet#4596
Context: a017561
Context: https://gist.github.com/pjcollins/87762e81f1f3c7e8b821356e4612eecf

A missing parameter in a call to `log_debug()` added in a017561 may
lead to a segfault when `assembly` log category and `debug` log level
are enabled:

	F libc    : Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x3 in tid 922 (DrawableTinting), pid 922 (DrawableTinting)
	I crash_dump64: obtaining output fd from tombstoned, type: kDebuggerdTombstone
	I /system/bin/tombstoned: received crash request for pid 922
	I crash_dump64: performing dump of process 922 (target tid = 922)
	F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
	F DEBUG   : Build fingerprint: 'Android/sdk_phone_x86_64/generic_x86_64:9/PSR1.180720.012/4923214:userdebug/test-keys'
	F DEBUG   : Revision: '0'
	F DEBUG   : ABI: 'x86_64'
	F DEBUG   : pid: 922, tid: 922, name: DrawableTinting  >>> com.xamarin.DrawableTinting <<<
	F DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x3
	F DEBUG   : Cause: null pointer dereference
	F DEBUG   :     rax 0000000000000000  rbx 00007ffed3c283c0  rcx 0000000000000003  rdx 0000000000000002
	F DEBUG   :     r8  00007ffed3c283c0  r9  00000000ffffffff  r10 00007ffed3c283d0  r11 00007ffed3c28824
	F DEBUG   :     r12 00007c88774a2f17  r13 00000000ffffffff  r14 0000000000000000  r15 00007ffed3c283d0
	F DEBUG   :     rdi 0000000000000003  rsi 00007ffed3c283bb
	F DEBUG   :     rbp 00007ffed3c28f18  rsp 00007ffed3c28288  rip 00007c890f860761
	F DEBUG   :
	F DEBUG   : backtrace:
	F DEBUG   :     #00 pc 0000000000020761  /system/lib64/libc.so (strlen+17)
	F DEBUG   :     #1 pc 000000000006e761  /system/lib64/libc.so (__vfprintf+5953)
	F DEBUG   :     dotnet#2 pc 000000000008df5d  /system/lib64/libc.so (vsnprintf+189)
	F DEBUG   :     dotnet#3 pc 0000000000007b60  /system/lib64/liblog.so (__android_log_vprint+64)
	F DEBUG   :     dotnet#4 pc 000000000001350c  /data/app/com.xamarin.DrawableTinting-zvchh4ya_DW11GfpEPFICw==/lib/x86_64/libmonodroid.so (log_debug_nocheck(_LogCategories, char const*, ...)+204)
	F DEBUG   :     dotnet#5 pc 000000000000de6a  /data/app/com.xamarin.DrawableTinting-zvchh4ya_DW11GfpEPFICw==/lib/x86_64/libmonodroid.so (xamarin::android::internal::EmbeddedAssemblies::typemap_java_to_managed(char const*)+538)
	F DEBUG   :     dotnet#6 pc 000000000000df13  /data/app/com.xamarin.DrawableTinting-zvchh4ya_DW11GfpEPFICw==/lib/x86_64/libmonodroid.so (xamarin::android::internal::EmbeddedAssemblies::typemap_java_to_managed(_MonoString*)+99)
	F DEBUG   :     dotnet#7 pc 00000000000d57f8  <anonymous:0000000042d04000>

Add the missing parameter to prevent the `SIGSEGV` from happening.n a017561 may lead
to a segfault when `assembly` log category and `debug` log level are
enabled:

		F libc    : Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x3 in tid 922 (DrawableTinting), pid 922 (DrawableTinting)
		I crash_dump64: obtaining output fd from tombstoned, type: kDebuggerdTombstone
		I /system/bin/tombstoned: received crash request for pid 922
		I crash_dump64: performing dump of process 922 (target tid = 922)
		F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
		F DEBUG   : Build fingerprint: 'Android/sdk_phone_x86_64/generic_x86_64:9/PSR1.180720.012/4923214:userdebug/test-keys'
		F DEBUG   : Revision: '0'
		F DEBUG   : ABI: 'x86_64'
		F DEBUG   : pid: 922, tid: 922, name: DrawableTinting  >>> com.xamarin.DrawableTinting <<<
		F DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x3
		F DEBUG   : Cause: null pointer dereference
		F DEBUG   :     rax 0000000000000000  rbx 00007ffed3c283c0  rcx 0000000000000003  rdx 0000000000000002
		F DEBUG   :     r8  00007ffed3c283c0  r9  00000000ffffffff  r10 00007ffed3c283d0  r11 00007ffed3c28824
		F DEBUG   :     r12 00007c88774a2f17  r13 00000000ffffffff  r14 0000000000000000  r15 00007ffed3c283d0
		F DEBUG   :     rdi 0000000000000003  rsi 00007ffed3c283bb
		F DEBUG   :     rbp 00007ffed3c28f18  rsp 00007ffed3c28288  rip 00007c890f860761
		F DEBUG   :
		F DEBUG   : backtrace:
		F DEBUG   :     #00 pc 0000000000020761  /system/lib64/libc.so (strlen+17)
		F DEBUG   :     #1 pc 000000000006e761  /system/lib64/libc.so (__vfprintf+5953)
		F DEBUG   :     dotnet#2 pc 000000000008df5d  /system/lib64/libc.so (vsnprintf+189)
		F DEBUG   :     dotnet#3 pc 0000000000007b60  /system/lib64/liblog.so (__android_log_vprint+64)
		F DEBUG   :     dotnet#4 pc 000000000001350c  /data/app/com.xamarin.DrawableTinting-zvchh4ya_DW11GfpEPFICw==/lib/x86_64/libmonodroid.so (log_debug_nocheck(_LogCategories, char const*, ...)+204)
		F DEBUG   :     dotnet#5 pc 000000000000de6a  /data/app/com.xamarin.DrawableTinting-zvchh4ya_DW11GfpEPFICw==/lib/x86_64/libmonodroid.so (xamarin::android::internal::EmbeddedAssemblies::typemap_java_to_managed(char const*)+538)
		F DEBUG   :     dotnet#6 pc 000000000000df13  /data/app/com.xamarin.DrawableTinting-zvchh4ya_DW11GfpEPFICw==/lib/x86_64/libmonodroid.so (xamarin::android::internal::EmbeddedAssemblies::typemap_java_to_managed(_MonoString*)+99)
		F DEBUG   :     dotnet#7 pc 00000000000d57f8  <anonymous:0000000042d04000>

Add the missing parameter to prevent the `SIGSEGV` from happening.
brendanzagaeski pushed a commit that referenced this pull request Jun 5, 2020
Fixes: dotnet#4713

Context: mono/mono@10795da1c065c
Context: mono/mono@8c085a99b32e9

Changes: mono/mono@075c3f0...8c085a9

  * mono/mono@8c085a99b32: [reflection] Check whether a pointer is valid before dereferencing (#19842)
  * mono/mono@89d772a3abb: Always include Unicode charinfo, so tar made in csc mode works in mcs mode (#19813)
  * mono/mono@e9d3af508e4: Bump bockbuild to get mono/bockbuild#159
  * mono/mono@d6f0c25d34d: [2020-02] Bump msbuild to track mono-2019-12 (#19661)

Whenever Xamarin.Android runtime needs to instantiate a managed type,
it first looks it up by calling:

	MonoType *type = mono_reflection_type_from_name ("MyType, Assembly", nullptr);

The `nullptr` pointer refers to an instance of the Mono `MonoImage`
structure and if `nullptr`, it should cause Mono to find the correct
image containing the type and load it, if not already loaded.

The pointer is propagated down the call chain inside Mono and due to
one of the functions called not properly validating its arguments, the
`nullptr` pointer was dereferenced, leading to a crash similar to:

	libc    : Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x4c0 in tid 11029 (ompanyname.app3), pid 11029 (ompanyname.app3)
	crash_dump64: obtaining output fd from tombstoned, type: kDebuggerdTombstone
	/system/bin/tombstoned: received crash request for pid 11029
	crash_dump64: performing dump of process 11029 (target tid = 11029)
	DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
	DEBUG   : Build fingerprint: 'google/sdk_gphone_x86_64/generic_x86_64:10/QSR1.190920.001/5891938:user/release-keys'
	DEBUG   : Revision: '0'
	DEBUG   : ABI: 'x86_64'
	DEBUG   : Timestamp: 2020-05-25 14:45:29+0200
	DEBUG   : pid: 11029, tid: 11029, name: ompanyname.app3  >>> com.companyname.app3 <<<
	DEBUG   : uid: 10134
	DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x4c0
	DEBUG   : Cause: null pointer dereference
	DEBUG   :     rax 000000000000002f  rbx 0000000000000001  rcx 0000000000000000  rdx 0000000000000030
	DEBUG   :     r8  0000000000000003  r9  000000000013e2e2  r10 0173eed800000000  r11 0000000000000206
	DEBUG   :     r12 0000000000000000  r13 00007478530343c0  r14 00007478075eda33  r15 000074780763efb0
	DEBUG   :     rdi 0000000000000000  rsi 00007478e2cb14d0
	DEBUG   :     rbp 00007ffef3a35680  rsp 00007ffef3a355d0  rip 0000747807a4066a
	DEBUG   :
	DEBUG   : backtrace:
	DEBUG   :       #00 pc 00000000003ba66a  /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonosgen-2.0.so (_mono_reflection_get_type_from_info+474)
	DEBUG   :       #1 pc 00000000003ba3d1  /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonosgen-2.0.so (mono_reflection_type_from_name_checked+321)
	DEBUG   :       dotnet#2 pc 00000000003ba26d  /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonosgen-2.0.so (mono_reflection_type_from_name+125)
	DEBUG   :       dotnet#3 pc 000000000000ddb5  /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonodroid.so (xamarin::android::internal::EmbeddedAssemblies::typemap_java_to_managed(char const*)+389) (BuildId: 9952f1cfe0d910ae631abc73479f88eef34fd71d)
	DEBUG   :       dotnet#4 pc 000000000000def3  /data/app/com.companyname.app3-aQUF6Ge6_v-WaLb5i8Q7vw==/lib/x86_64/libmonodroid.so (xamarin::android::internal::EmbeddedAssemblies::typemap_java_to_managed(_MonoString*)+99) (BuildId: 9952f1cfe0d910ae631abc73479f88eef34fd71d)
	DEBUG   :       dotnet#5 pc 0000000000069532  <anonymous:5ad25000>

Mono commit mono/mono@10795da1c06 fixes this issue.
brendanzagaeski added a commit that referenced this pull request Jul 28, 2020
…abi-v7a

Context: dotnet#1218 (comment)

The undocumented, experimental `Hybrid` value for the
`$(AndroidAotMode)` MSBuild property is not currently compatible with
the armeabi-v7a target ABI.  Attempting to run an app built with
`$(AndroidAotMode)`=`Hybrid` in an armeabi-v7a environment results in a
crash.

Since it is known that this configuration currently produces a crash,
emit a build error for it to improve the visibility of the known issue
and reduce the time users might spend searching for the cause of the
crash.

Example of the current crash:

	F libc    : Fatal signal 11 (SIGSEGV), code 2, fault addr 0x913a50c8 in tid 31140 (ppxamarinforms1)
	W         : debuggerd: handling request: pid=31140 uid=10146 gid=10146 tid=31140
	F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
	F DEBUG   : Build fingerprint: 'motorola/perry_metropcs_c/perry:7.1.1/NCQS26.69-64-21/33:user/release-keys'
	F DEBUG   : Revision: 'p3b0'
	F DEBUG   : ABI: 'arm'
	F DEBUG   : pid: 31140, tid: 31140, name: ppxamarinforms1  >>> com.companyname.mobileappxamarinforms1 <<<
	F DEBUG   : signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x913a50c8
	F DEBUG   :     r0 be9384d4  r1 00000000  r2 be9385a0  r3 9320b1c0
	F DEBUG   :     r4 00000000  r5 94167208  r6 00000000  r7 be938584
	F DEBUG   :     r8 be938838  r9 ae040008  sl 00000000  fp be9385a0
	F DEBUG   :     ip 913a50c8  sp be9384e4  lr 942a8420  pc 913a50c8  cpsr 000f0010
	F DEBUG   :
	F DEBUG   : backtrace:
	F DEBUG   :     #00 pc 000250c8  [anon:libc_malloc:91380000]
	F DEBUG   :     #1 pc 0000141c  <anonymous:942a7000>
	W ActivityManager: Activity pause timeout for ActivityRecord{7ded4d1 u0 com.companyname.mobileappxamarinforms1/crc64e53dff5578afb8f2.MainActivity t5740}
	I ActivityManager: Killing 30471:com.google.android.apps.fireball/u0a145 (adj 906): empty dotnet#13
	D ConnectivityService: ConnectivityService NetworkRequestInfo binderDied(NetworkRequest [ LISTEN id=624, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&FOREGROUND] ], android.os.BinderProxy@f4c4e10)
	D ActivityManager: cleanUpApplicationRecord -- 30471
	E ConnectivityService: RemoteException caught trying to send a callback msg for NetworkRequest [ LISTEN id=624, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&FOREGROUND] ]
	W         : debuggerd: resuming target 31140
	I BootReceiver: Copying /data/tombstones/tombstone_05 to DropBox (SYSTEM_TOMBSTONE)
	W ActivityManager:   Force finishing activity com.companyname.mobileappxamarinforms1/crc64e53dff5578afb8f2.MainActivity
	I Zygote  : Process 31140 exited due to signal (11)
brendanzagaeski added a commit that referenced this pull request Jul 28, 2020
…abi-v7a

Context: dotnet#1218 (comment)

The undocumented, experimental `Hybrid` value for the
`$(AndroidAotMode)` MSBuild property is not currently compatible with
the armeabi-v7a target ABI.  Attempting to run an app built with
`$(AndroidAotMode)`=`Hybrid` in an armeabi-v7a environment results in a
crash.

Since it is known that this configuration currently produces a crash,
emit a build error for it to improve the visibility of the known issue
and reduce the time users might spend searching for the cause of the
crash.

Example of the current crash:

	F libc    : Fatal signal 11 (SIGSEGV), code 2, fault addr 0x913a50c8 in tid 31140 (ppxamarinforms1)
	W         : debuggerd: handling request: pid=31140 uid=10146 gid=10146 tid=31140
	F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
	F DEBUG   : Build fingerprint: 'motorola/perry_metropcs_c/perry:7.1.1/NCQS26.69-64-21/33:user/release-keys'
	F DEBUG   : Revision: 'p3b0'
	F DEBUG   : ABI: 'arm'
	F DEBUG   : pid: 31140, tid: 31140, name: ppxamarinforms1  >>> com.companyname.mobileappxamarinforms1 <<<
	F DEBUG   : signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x913a50c8
	F DEBUG   :     r0 be9384d4  r1 00000000  r2 be9385a0  r3 9320b1c0
	F DEBUG   :     r4 00000000  r5 94167208  r6 00000000  r7 be938584
	F DEBUG   :     r8 be938838  r9 ae040008  sl 00000000  fp be9385a0
	F DEBUG   :     ip 913a50c8  sp be9384e4  lr 942a8420  pc 913a50c8  cpsr 000f0010
	F DEBUG   :
	F DEBUG   : backtrace:
	F DEBUG   :     #00 pc 000250c8  [anon:libc_malloc:91380000]
	F DEBUG   :     #1 pc 0000141c  <anonymous:942a7000>
	W ActivityManager: Activity pause timeout for ActivityRecord{7ded4d1 u0 com.companyname.mobileappxamarinforms1/crc64e53dff5578afb8f2.MainActivity t5740}
	I ActivityManager: Killing 30471:com.google.android.apps.fireball/u0a145 (adj 906): empty dotnet#13
	D ConnectivityService: ConnectivityService NetworkRequestInfo binderDied(NetworkRequest [ LISTEN id=624, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&FOREGROUND] ], android.os.BinderProxy@f4c4e10)
	D ActivityManager: cleanUpApplicationRecord -- 30471
	E ConnectivityService: RemoteException caught trying to send a callback msg for NetworkRequest [ LISTEN id=624, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&FOREGROUND] ]
	W         : debuggerd: resuming target 31140
	I BootReceiver: Copying /data/tombstones/tombstone_05 to DropBox (SYSTEM_TOMBSTONE)
	W ActivityManager:   Force finishing activity com.companyname.mobileappxamarinforms1/crc64e53dff5578afb8f2.MainActivity
	I Zygote  : Process 31140 exited due to signal (11)

Other changes:

Update the `HybridAOT` test to cover the new error.

Correct the `BuildIncrementalAot` test so that it sets
`$(AndroidSupportedAbis)`.  A side-effect is that the test cases that
use `$(AndroidAotMode)`=`Full` now build successfully.  Note that
although those test cases now build successfully, the resulting app
packages abort when run on device because Xamarin.Android requires JIT
compilation:

	Unhandled Exception:
	System.ExecutionEngineException: Attempting to JIT compile method '(wrapper other) void Java.Interop.JavaVMInterface:PtrToStructure (intptr,object)' while running in aot-only mode.

TODO: Add a build error for `$(AndroidAotMode)`=`Full`, likely by
updating error XA3002.
brendanzagaeski added a commit that referenced this pull request Jul 29, 2020
…abi-v7a

Context: dotnet#1218 (comment)

The undocumented, experimental `Hybrid` value for the
`$(AndroidAotMode)` MSBuild property is not currently compatible with
the armeabi-v7a target ABI.  Attempting to run an app built with
`$(AndroidAotMode)`=`Hybrid` in an armeabi-v7a environment results in a
crash.

Since it is known that this configuration currently produces a crash,
emit a build error for it to improve the visibility of the known issue
and reduce the time users might spend searching for the cause of the
crash.

Example of the current crash:

	F libc    : Fatal signal 11 (SIGSEGV), code 2, fault addr 0x913a50c8 in tid 31140 (ppxamarinforms1)
	W         : debuggerd: handling request: pid=31140 uid=10146 gid=10146 tid=31140
	F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
	F DEBUG   : Build fingerprint: 'motorola/perry_metropcs_c/perry:7.1.1/NCQS26.69-64-21/33:user/release-keys'
	F DEBUG   : Revision: 'p3b0'
	F DEBUG   : ABI: 'arm'
	F DEBUG   : pid: 31140, tid: 31140, name: ppxamarinforms1  >>> com.companyname.mobileappxamarinforms1 <<<
	F DEBUG   : signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x913a50c8
	F DEBUG   :     r0 be9384d4  r1 00000000  r2 be9385a0  r3 9320b1c0
	F DEBUG   :     r4 00000000  r5 94167208  r6 00000000  r7 be938584
	F DEBUG   :     r8 be938838  r9 ae040008  sl 00000000  fp be9385a0
	F DEBUG   :     ip 913a50c8  sp be9384e4  lr 942a8420  pc 913a50c8  cpsr 000f0010
	F DEBUG   :
	F DEBUG   : backtrace:
	F DEBUG   :     #00 pc 000250c8  [anon:libc_malloc:91380000]
	F DEBUG   :     #1 pc 0000141c  <anonymous:942a7000>
	W ActivityManager: Activity pause timeout for ActivityRecord{7ded4d1 u0 com.companyname.mobileappxamarinforms1/crc64e53dff5578afb8f2.MainActivity t5740}
	I ActivityManager: Killing 30471:com.google.android.apps.fireball/u0a145 (adj 906): empty dotnet#13
	D ConnectivityService: ConnectivityService NetworkRequestInfo binderDied(NetworkRequest [ LISTEN id=624, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&FOREGROUND] ], android.os.BinderProxy@f4c4e10)
	D ActivityManager: cleanUpApplicationRecord -- 30471
	E ConnectivityService: RemoteException caught trying to send a callback msg for NetworkRequest [ LISTEN id=624, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&FOREGROUND] ]
	W         : debuggerd: resuming target 31140
	I BootReceiver: Copying /data/tombstones/tombstone_05 to DropBox (SYSTEM_TOMBSTONE)
	W ActivityManager:   Force finishing activity com.companyname.mobileappxamarinforms1/crc64e53dff5578afb8f2.MainActivity
	I Zygote  : Process 31140 exited due to signal (11)

Other changes:

Update the `HybridAOT` test to cover the new error.

Correct the `BuildIncrementalAot` test so that it sets
`$(AndroidSupportedAbis)`.  A side effect is that the test cases that
use `$(AndroidAotMode)`=`Full` now build successfully.  Note that
although those test cases now build successfully, the resulting app
packages abort when run on device because Xamarin.Android requires JIT
compilation:

	Unhandled Exception:
	System.ExecutionEngineException: Attempting to JIT compile method '(wrapper other) void Java.Interop.JavaVMInterface:PtrToStructure (intptr,object)' while running in aot-only mode.

TODO: Add a build error for `$(AndroidAotMode)`=`Full`, likely by
updating error XA3002.
brendanzagaeski added a commit that referenced this pull request Nov 8, 2020
…abi-v7a

Context: dotnet#1218 (comment)

The undocumented, experimental `Hybrid` value for the
`$(AndroidAotMode)` MSBuild property is not currently compatible with
the armeabi-v7a target ABI.  Attempting to run an app built with
`$(AndroidAotMode)`=`Hybrid` in an armeabi-v7a environment results in a
crash.

Since it is known that this configuration currently produces a crash,
emit a build error for it to improve the visibility of the known issue
and reduce the time users might spend searching for the cause of the
crash.

Example of the current crash:

	F libc    : Fatal signal 11 (SIGSEGV), code 2, fault addr 0x913a50c8 in tid 31140 (ppxamarinforms1)
	W         : debuggerd: handling request: pid=31140 uid=10146 gid=10146 tid=31140
	F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
	F DEBUG   : Build fingerprint: 'motorola/perry_metropcs_c/perry:7.1.1/NCQS26.69-64-21/33:user/release-keys'
	F DEBUG   : Revision: 'p3b0'
	F DEBUG   : ABI: 'arm'
	F DEBUG   : pid: 31140, tid: 31140, name: ppxamarinforms1  >>> com.companyname.mobileappxamarinforms1 <<<
	F DEBUG   : signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x913a50c8
	F DEBUG   :     r0 be9384d4  r1 00000000  r2 be9385a0  r3 9320b1c0
	F DEBUG   :     r4 00000000  r5 94167208  r6 00000000  r7 be938584
	F DEBUG   :     r8 be938838  r9 ae040008  sl 00000000  fp be9385a0
	F DEBUG   :     ip 913a50c8  sp be9384e4  lr 942a8420  pc 913a50c8  cpsr 000f0010
	F DEBUG   :
	F DEBUG   : backtrace:
	F DEBUG   :     #00 pc 000250c8  [anon:libc_malloc:91380000]
	F DEBUG   :     #1 pc 0000141c  <anonymous:942a7000>
	W ActivityManager: Activity pause timeout for ActivityRecord{7ded4d1 u0 com.companyname.mobileappxamarinforms1/crc64e53dff5578afb8f2.MainActivity t5740}
	I ActivityManager: Killing 30471:com.google.android.apps.fireball/u0a145 (adj 906): empty dotnet#13
	D ConnectivityService: ConnectivityService NetworkRequestInfo binderDied(NetworkRequest [ LISTEN id=624, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&FOREGROUND] ], android.os.BinderProxy@f4c4e10)
	D ActivityManager: cleanUpApplicationRecord -- 30471
	E ConnectivityService: RemoteException caught trying to send a callback msg for NetworkRequest [ LISTEN id=624, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&FOREGROUND] ]
	W         : debuggerd: resuming target 31140
	I BootReceiver: Copying /data/tombstones/tombstone_05 to DropBox (SYSTEM_TOMBSTONE)
	W ActivityManager:   Force finishing activity com.companyname.mobileappxamarinforms1/crc64e53dff5578afb8f2.MainActivity
	I Zygote  : Process 31140 exited due to signal (11)

Other changes:

Update the `HybridAOT` test to cover the new error.

Correct the `BuildIncrementalAot` test so that it sets
`$(AndroidSupportedAbis)`.  A side effect is that the test cases that
use `$(AndroidAotMode)`=`Full` now build successfully.  Note that
although those test cases now build successfully, the resulting app
packages abort when run on device because Xamarin.Android requires JIT
compilation:

	Unhandled Exception:
	System.ExecutionEngineException: Attempting to JIT compile method '(wrapper other) void Java.Interop.JavaVMInterface:PtrToStructure (intptr,object)' while running in aot-only mode.

TODO: Add a build error for `$(AndroidAotMode)`=`Full`, likely by
updating error XA3002.
brendanzagaeski added a commit that referenced this pull request Nov 8, 2020
…abi-v7a

Context: dotnet#1218 (comment)

The undocumented, experimental `Hybrid` value for the
`$(AndroidAotMode)` MSBuild property is not currently compatible with
the armeabi-v7a target ABI.  Attempting to run an app built with
`$(AndroidAotMode)`=`Hybrid` in an armeabi-v7a environment results in a
crash.

Since it is known that this configuration currently produces a crash,
emit a build error for it to improve the visibility of the known issue
and reduce the time users might spend searching for the cause of the
crash.

Example of the current crash:

	F libc    : Fatal signal 11 (SIGSEGV), code 2, fault addr 0x913a50c8 in tid 31140 (ppxamarinforms1)
	W         : debuggerd: handling request: pid=31140 uid=10146 gid=10146 tid=31140
	F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
	F DEBUG   : Build fingerprint: 'motorola/perry_metropcs_c/perry:7.1.1/NCQS26.69-64-21/33:user/release-keys'
	F DEBUG   : Revision: 'p3b0'
	F DEBUG   : ABI: 'arm'
	F DEBUG   : pid: 31140, tid: 31140, name: ppxamarinforms1  >>> com.companyname.mobileappxamarinforms1 <<<
	F DEBUG   : signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x913a50c8
	F DEBUG   :     r0 be9384d4  r1 00000000  r2 be9385a0  r3 9320b1c0
	F DEBUG   :     r4 00000000  r5 94167208  r6 00000000  r7 be938584
	F DEBUG   :     r8 be938838  r9 ae040008  sl 00000000  fp be9385a0
	F DEBUG   :     ip 913a50c8  sp be9384e4  lr 942a8420  pc 913a50c8  cpsr 000f0010
	F DEBUG   :
	F DEBUG   : backtrace:
	F DEBUG   :     #00 pc 000250c8  [anon:libc_malloc:91380000]
	F DEBUG   :     #1 pc 0000141c  <anonymous:942a7000>
	W ActivityManager: Activity pause timeout for ActivityRecord{7ded4d1 u0 com.companyname.mobileappxamarinforms1/crc64e53dff5578afb8f2.MainActivity t5740}
	I ActivityManager: Killing 30471:com.google.android.apps.fireball/u0a145 (adj 906): empty dotnet#13
	D ConnectivityService: ConnectivityService NetworkRequestInfo binderDied(NetworkRequest [ LISTEN id=624, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&FOREGROUND] ], android.os.BinderProxy@f4c4e10)
	D ActivityManager: cleanUpApplicationRecord -- 30471
	E ConnectivityService: RemoteException caught trying to send a callback msg for NetworkRequest [ LISTEN id=624, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&FOREGROUND] ]
	W         : debuggerd: resuming target 31140
	I BootReceiver: Copying /data/tombstones/tombstone_05 to DropBox (SYSTEM_TOMBSTONE)
	W ActivityManager:   Force finishing activity com.companyname.mobileappxamarinforms1/crc64e53dff5578afb8f2.MainActivity
	I Zygote  : Process 31140 exited due to signal (11)

Other changes:

Update the `HybridAOT` test to cover the new error.

Correct the `BuildIncrementalAot` test so that it sets
`$(AndroidSupportedAbis)`.  A side effect is that the test cases that
use `$(AndroidAotMode)`=`Full` now build successfully.  Note that
although those test cases now build successfully, the resulting app
packages abort when run on device because Xamarin.Android requires JIT
compilation:

	Unhandled Exception:
	System.ExecutionEngineException: Attempting to JIT compile method '(wrapper other) void Java.Interop.JavaVMInterface:PtrToStructure (intptr,object)' while running in aot-only mode.

TODO: Add a build error for `$(AndroidAotMode)`=`Full`, likely by
updating error XA3002.
brendanzagaeski added a commit that referenced this pull request Nov 12, 2020
…abi-v7a

Context: dotnet#1218 (comment)

The undocumented, experimental `Hybrid` value for the
`$(AndroidAotMode)` MSBuild property is not currently compatible with
the armeabi-v7a target ABI.  Attempting to run an app built with
`$(AndroidAotMode)`=`Hybrid` in an armeabi-v7a environment results in a
crash.

Since it is known that this configuration currently produces a crash,
emit a build error for it to improve the visibility of the known issue
and reduce the time users might spend searching for the cause of the
crash.

Example of the current crash:

	F libc    : Fatal signal 11 (SIGSEGV), code 2, fault addr 0x913a50c8 in tid 31140 (ppxamarinforms1)
	W         : debuggerd: handling request: pid=31140 uid=10146 gid=10146 tid=31140
	F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
	F DEBUG   : Build fingerprint: 'motorola/perry_metropcs_c/perry:7.1.1/NCQS26.69-64-21/33:user/release-keys'
	F DEBUG   : Revision: 'p3b0'
	F DEBUG   : ABI: 'arm'
	F DEBUG   : pid: 31140, tid: 31140, name: ppxamarinforms1  >>> com.companyname.mobileappxamarinforms1 <<<
	F DEBUG   : signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x913a50c8
	F DEBUG   :     r0 be9384d4  r1 00000000  r2 be9385a0  r3 9320b1c0
	F DEBUG   :     r4 00000000  r5 94167208  r6 00000000  r7 be938584
	F DEBUG   :     r8 be938838  r9 ae040008  sl 00000000  fp be9385a0
	F DEBUG   :     ip 913a50c8  sp be9384e4  lr 942a8420  pc 913a50c8  cpsr 000f0010
	F DEBUG   :
	F DEBUG   : backtrace:
	F DEBUG   :     #00 pc 000250c8  [anon:libc_malloc:91380000]
	F DEBUG   :     #1 pc 0000141c  <anonymous:942a7000>
	W ActivityManager: Activity pause timeout for ActivityRecord{7ded4d1 u0 com.companyname.mobileappxamarinforms1/crc64e53dff5578afb8f2.MainActivity t5740}
	I ActivityManager: Killing 30471:com.google.android.apps.fireball/u0a145 (adj 906): empty dotnet#13
	D ConnectivityService: ConnectivityService NetworkRequestInfo binderDied(NetworkRequest [ LISTEN id=624, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&FOREGROUND] ], android.os.BinderProxy@f4c4e10)
	D ActivityManager: cleanUpApplicationRecord -- 30471
	E ConnectivityService: RemoteException caught trying to send a callback msg for NetworkRequest [ LISTEN id=624, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&FOREGROUND] ]
	W         : debuggerd: resuming target 31140
	I BootReceiver: Copying /data/tombstones/tombstone_05 to DropBox (SYSTEM_TOMBSTONE)
	W ActivityManager:   Force finishing activity com.companyname.mobileappxamarinforms1/crc64e53dff5578afb8f2.MainActivity
	I Zygote  : Process 31140 exited due to signal (11)

Other changes:

Update the `HybridAOT` test to cover the new error.

Add a new `AndroidAotModeHybridAbortsOnArmeabiV7a` on-device test to
remind the team to remove the error if hybrid AOT becomes compatible
with armeabi-v7a in the future.

Correct the `BuildIncrementalAot` test so that it sets
`$(AndroidSupportedAbis)`.  A side effect is that the test cases that
use `$(AndroidAotMode)`=`Full` now build successfully.  Note that
although those test cases now build successfully, the resulting app
packages abort when run on device because Xamarin.Android requires JIT
compilation:

	Unhandled Exception:
	System.ExecutionEngineException: Attempting to JIT compile method '(wrapper other) void Java.Interop.JavaVMInterface:PtrToStructure (intptr,object)' while running in aot-only mode.

TODO: Add a build error for `$(AndroidAotMode)`=`Full`, likely by
updating error XA3002.
brendanzagaeski added a commit that referenced this pull request Nov 12, 2020
…abi-v7a

Context: dotnet#1218 (comment)

The undocumented, experimental `Hybrid` value for the
`$(AndroidAotMode)` MSBuild property is not currently compatible with
the armeabi-v7a target ABI.  Attempting to run an app built with
`$(AndroidAotMode)`=`Hybrid` in an armeabi-v7a environment results in a
crash.

Since it is known that this configuration currently produces a crash,
emit a build error for it to improve the visibility of the known issue
and reduce the time users might spend searching for the cause of the
crash.

Example of the current crash:

	F libc    : Fatal signal 11 (SIGSEGV), code 2, fault addr 0x913a50c8 in tid 31140 (ppxamarinforms1)
	W         : debuggerd: handling request: pid=31140 uid=10146 gid=10146 tid=31140
	F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
	F DEBUG   : Build fingerprint: 'motorola/perry_metropcs_c/perry:7.1.1/NCQS26.69-64-21/33:user/release-keys'
	F DEBUG   : Revision: 'p3b0'
	F DEBUG   : ABI: 'arm'
	F DEBUG   : pid: 31140, tid: 31140, name: ppxamarinforms1  >>> com.companyname.mobileappxamarinforms1 <<<
	F DEBUG   : signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x913a50c8
	F DEBUG   :     r0 be9384d4  r1 00000000  r2 be9385a0  r3 9320b1c0
	F DEBUG   :     r4 00000000  r5 94167208  r6 00000000  r7 be938584
	F DEBUG   :     r8 be938838  r9 ae040008  sl 00000000  fp be9385a0
	F DEBUG   :     ip 913a50c8  sp be9384e4  lr 942a8420  pc 913a50c8  cpsr 000f0010
	F DEBUG   :
	F DEBUG   : backtrace:
	F DEBUG   :     #00 pc 000250c8  [anon:libc_malloc:91380000]
	F DEBUG   :     #1 pc 0000141c  <anonymous:942a7000>
	W ActivityManager: Activity pause timeout for ActivityRecord{7ded4d1 u0 com.companyname.mobileappxamarinforms1/crc64e53dff5578afb8f2.MainActivity t5740}
	I ActivityManager: Killing 30471:com.google.android.apps.fireball/u0a145 (adj 906): empty dotnet#13
	D ConnectivityService: ConnectivityService NetworkRequestInfo binderDied(NetworkRequest [ LISTEN id=624, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&FOREGROUND] ], android.os.BinderProxy@f4c4e10)
	D ActivityManager: cleanUpApplicationRecord -- 30471
	E ConnectivityService: RemoteException caught trying to send a callback msg for NetworkRequest [ LISTEN id=624, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&FOREGROUND] ]
	W         : debuggerd: resuming target 31140
	I BootReceiver: Copying /data/tombstones/tombstone_05 to DropBox (SYSTEM_TOMBSTONE)
	W ActivityManager:   Force finishing activity com.companyname.mobileappxamarinforms1/crc64e53dff5578afb8f2.MainActivity
	I Zygote  : Process 31140 exited due to signal (11)

Other changes:

Update the `HybridAOT` test to cover the new error.

Correct the `BuildIncrementalAot` test so that it sets
`$(AndroidSupportedAbis)`.  A side effect is that the test cases that
use `$(AndroidAotMode)`=`Full` now build successfully.  Note that
although those test cases now build successfully, the resulting app
packages abort when run on device because Xamarin.Android requires JIT
compilation:

	Unhandled Exception:
	System.ExecutionEngineException: Attempting to JIT compile method '(wrapper other) void Java.Interop.JavaVMInterface:PtrToStructure (intptr,object)' while running in aot-only mode.

TODO: Add a build error for `$(AndroidAotMode)`=`Full`, likely by
updating error XA3002.
jonpryor pushed a commit that referenced this pull request Dec 9, 2020
…5365)

Context: dotnet#5167

The `Android.Runtime.Extensions` type is not accessed via reflection.

It *is* preserved by the linker when needed, e.g.:

	$ illinkanalyzer -r Android.Runtime.Extensions linker-dependencies.xml.gz
	…
	--- Method:TResult Android.Runtime.Extensions::JavaCast(Android.Runtime.IJavaObject) dependencies ---
	Dependency #1
	        Method:TResult Android.Runtime.Extensions::JavaCast(Android.Runtime.IJavaObject)
	        | MethodSpec:TResult Android.Runtime.Extensions::JavaCast<T>(Android.Runtime.IJavaObject) [1 deps]
	        | Method:T Android.App.Activity::FindViewById(System.Int32) [1 deps]
	        | MethodSpec:!!0 Android.App.Activity::FindViewById<Android.Widget.Button>(System.Int32) [1 deps]
	        | Method:System.Void UnnamedProject.MainActivity::OnCreate(Android.OS.Bundle) [2 deps]
	        | Assembly:UnnamedProject, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null [1 deps]
	        | Other:Copy
	…
jonpryor pushed a commit that referenced this pull request Dec 9, 2020
…otnet#4966)

Context: dotnet#1218 (comment)

The undocumented, experimental, `Hybrid` value for the
`$(AndroidAotMode)` MSBuild property is not currently compatible with
the armeabi-v7a target ABI.  Attempting to run an app built with
`$(AndroidAotMode)`=`Hybrid` in an armeabi-v7a environment results in
a crash:

	F libc    : Fatal signal 11 (SIGSEGV), code 2, fault addr 0x913a50c8 in tid 31140 (ppxamarinforms1)
	W         : debuggerd: handling request: pid=31140 uid=10146 gid=10146 tid=31140
	F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
	F DEBUG   : Build fingerprint: 'motorola/perry_metropcs_c/perry:7.1.1/NCQS26.69-64-21/33:user/release-keys'
	F DEBUG   : Revision: 'p3b0'
	F DEBUG   : ABI: 'arm'
	F DEBUG   : pid: 31140, tid: 31140, name: ppxamarinforms1  >>> com.companyname.mobileappxamarinforms1 <<<
	F DEBUG   : signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x913a50c8
	F DEBUG   :     r0 be9384d4  r1 00000000  r2 be9385a0  r3 9320b1c0
	F DEBUG   :     r4 00000000  r5 94167208  r6 00000000  r7 be938584
	F DEBUG   :     r8 be938838  r9 ae040008  sl 00000000  fp be9385a0
	F DEBUG   :     ip 913a50c8  sp be9384e4  lr 942a8420  pc 913a50c8  cpsr 000f0010
	F DEBUG   :
	F DEBUG   : backtrace:
	F DEBUG   :     #00 pc 000250c8  [anon:libc_malloc:91380000]
	F DEBUG   :     #1 pc 0000141c  <anonymous:942a7000>
	W ActivityManager: Activity pause timeout for ActivityRecord{7ded4d1 u0 com.companyname.mobileappxamarinforms1/crc64e53dff5578afb8f2.MainActivity t5740}
	I ActivityManager: Killing 30471:com.google.android.apps.fireball/u0a145 (adj 906): empty dotnet#13
	D ConnectivityService: ConnectivityService NetworkRequestInfo binderDied(NetworkRequest [ LISTEN id=624, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&FOREGROUND] ], android.os.BinderProxy@f4c4e10)
	D ActivityManager: cleanUpApplicationRecord -- 30471
	E ConnectivityService: RemoteException caught trying to send a callback msg for NetworkRequest [ LISTEN id=624, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&FOREGROUND] ]
	W         : debuggerd: resuming target 31140
	I BootReceiver: Copying /data/tombstones/tombstone_05 to DropBox (SYSTEM_TOMBSTONE)
	W ActivityManager:   Force finishing activity com.companyname.mobileappxamarinforms1/crc64e53dff5578afb8f2.MainActivity
	I Zygote  : Process 31140 exited due to signal (11)

Since it is known that this configuration currently produces a crash,
emit a build error for it to improve the visibility of the known
issue and reduce the time users might spend searching for the cause
of the crash.

Other changes:

Update the `HybridAOT` test to cover the new error.

Correct the `IncrementalBuildTest.BuildIncrementalAot()` test so that
it sets `$(AndroidSupportedAbis)`.  A side effect is that the test
cases that use `$(AndroidAotMode)`=`Full` now build successfully.
Note that although those test cases now build successfully, the
resulting app packages abort when run on device because Xamarin.Android
requires JIT compilation:

	Unhandled Exception:
	System.ExecutionEngineException: Attempting to JIT compile method '(wrapper other) void Java.Interop.JavaVMInterface:PtrToStructure (intptr,object)' while running in aot-only mode.

TODO: Add a build error for `$(AndroidAotMode)`=`Full`, likely by
updating error XA3002.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant