Skip to content
This repository was archived by the owner on Jul 6, 2026. It is now read-only.

[jnimarshalmethod-gen] Fix type resolution crash - #706

Merged
radekdoulik merged 1 commit into
dotnet:masterfrom
radekdoulik:pr-fix-type-resolution-crash
Sep 8, 2020
Merged

[jnimarshalmethod-gen] Fix type resolution crash#706
radekdoulik merged 1 commit into
dotnet:masterfrom
radekdoulik:pr-fix-type-resolution-crash

Conversation

@radekdoulik

@radekdoulikradekdoulik commented Sep 3, 2020

Copy link
Copy Markdown
Member

The TypeMover was crashing, when we cannot resolve the type during
register method optimization.

Like this:

Value cannot be null.
Parameter name: key
System.ArgumentNullException: Value cannot be null.
Parameter name: key
at System.Collections.Generic.Dictionary`2[TKey,TValue].FindEntry (TKey key) [0x00175] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/debug/external/corefx/src/Common/src/CoreLib/System/Collections/Generic/Dictionary.cs:470
at System.Collections.Generic.Dictionary`2[TKey,TValue].ContainsKey (TKey key) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/debug/external/corefx/src/Common/src/CoreLib/System/Collections/Generic/Dictionary.cs:286
at Xamarin.Android.Tools.JniMarshalMethodGenerator.TypeMover.Resolve (Mono.Cecil.TypeReference type) [0x00001] in /Users/rodo/git/xa-clean/external/Java.Interop/tools/jnimarshalmethod-gen/TypeMover.cs:143
at Xamarin.Android.Tools.JniMarshalMethodGenerator.TypeMover.GetActionConstructor (Mono.Cecil.TypeReference type, Mono.Cecil.ModuleDefinition module) [0x00012] in /Users/rodo/git/xa-clean/external/Java.Interop/tools/jnimarshalmethod-gen/TypeMover.cs:335
at Xamarin.Android.Tools.JniMarshalMethodGenerator.TypeMover.AnalyzeAndImprove (Mono.Collections.Generic.Collection`1[T] instructions, Mono.Collections.Generic.Collection`1[T] newInstructions, System.Int32 idx, System.String typeName, System.Int32& skipCount, Mono.Cecil.ModuleDefinition module) [0x003b6] in /Users/rodo/git/xa-clean/external/Java.Interop/tools/jnimarshalmethod-gen/TypeMover.cs:417

The tool was crashing on IL like this:

IL_0122: ldstr "Delegate18$1"
IL_0127: ldc.i4.1
IL_0128: call [mscorlib]System.Type [mscorlib]System.Type::GetType(string,
bool)

The fix makes us more error resistant. It doesn't fix the source of the problem,
which will be fixed elsewhere.

More information about the issue which led to the crash: https://github.com/xamarin/java.interop/issues/709

The TypeMover was crashing, when we cannot resolve the type during
register method optimization.
Like this:
Value cannot be null.
Parameter name: key
System.ArgumentNullException: Value cannot be null.
Parameter name: key
at System.Collections.Generic.Dictionary`2[TKey,TValue].FindEntry (TKey key) [0x00175] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/debug/external/corefx/src/Common/src/CoreLib/System/Collections/Generic/Dictionary.cs:470
at System.Collections.Generic.Dictionary`2[TKey,TValue].ContainsKey (TKey key) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/debug/external/corefx/src/Common/src/CoreLib/System/Collections/Generic/Dictionary.cs:286
at Xamarin.Android.Tools.JniMarshalMethodGenerator.TypeMover.Resolve (Mono.Cecil.TypeReference type) [0x00001] in /Users/rodo/git/xa-clean/external/Java.Interop/tools/jnimarshalmethod-gen/TypeMover.cs:143
at Xamarin.Android.Tools.JniMarshalMethodGenerator.TypeMover.GetActionConstructor (Mono.Cecil.TypeReference type, Mono.Cecil.ModuleDefinition module) [0x00012] in /Users/rodo/git/xa-clean/external/Java.Interop/tools/jnimarshalmethod-gen/TypeMover.cs:335
at Xamarin.Android.Tools.JniMarshalMethodGenerator.TypeMover.AnalyzeAndImprove (Mono.Collections.Generic.Collection`1[T] instructions, Mono.Collections.Generic.Collection`1[T] newInstructions, System.Int32 idx, System.String typeName, System.Int32& skipCount, Mono.Cecil.ModuleDefinition module) [0x003b6] in /Users/rodo/git/xa-clean/external/Java.Interop/tools/jnimarshalmethod-gen/TypeMover.cs:417
The tool was crashing on IL like this:
IL_0122: ldstr "Delegate18$1"
IL_0127: ldc.i4.1
IL_0128: call [mscorlib]System.Type [mscorlib]System.Type::GetType(string,
bool)
The fix makes us more error prone. It doesn't fix the source of the problem,
which will be fixed elsewhere.
@radekdoulik

Copy link
Copy Markdown
MemberAuthor

Context: the issue which leads to and exposes the crash is being fixed in #711

@radekdoulik
radekdoulik merged commit 03c2272 into dotnet:masterSep 8, 2020
@jpobstjpobst added this to the 11.1 (16.9 / 8.9) milestone Sep 22, 2020
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Apr 13, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@radekdoulik@jpobst