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

[mono][aot] Baseservices runtime tests failed in Mono fullAOT llvm job #92883

Closed
kotlarmilos opened this issue Oct 2, 2023 · 0 comments · Fixed by #101732
Closed

[mono][aot] Baseservices runtime tests failed in Mono fullAOT llvm job #92883

kotlarmilos opened this issue Oct 2, 2023 · 0 comments · Fixed by #101732
Assignees
Labels
area-Codegen-AOT-mono disabled-test The test is disabled in source code against the issue in-pr There is an active PR which will close this issue when it is merged
Milestone

Comments

@kotlarmilos
Copy link
Member

Below are the tests that failed in the test run https://dev.azure.com/dnceng-public/public/_build/results?buildId=422831&view=logs&jobId=c38ec756-eb98-514e-2413-35443f23bc13.

UnsafeAccessorsTests.dll

BEGIN EXECUTION
/datadisks/disk1/work/A41708E9/p/corerun -p Microsoft.Extensions.DependencyInjection.VerifyOpenGenericServiceTrimmability=true -p System.ComponentModel.TypeConverter.EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization=false -p System.Reflection.Metadata.MetadataUpdater.IsSupported=false -p System.Resources.ResourceManager.AllowCustomResourceTypes=false -p System.Runtime.InteropServices.BuiltInComInterop.IsSupported=false -p System.Runtime.InteropServices.EnableConsumingManagedCodeFromNativeHosting=false -p System.Runtime.InteropServices.EnableCppCLIHostActivation=false -p System.Runtime.InteropServices.Marshalling.EnableGeneratedComInterfaceComImportInterop=false -p System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization=true -p System.StartupHookProvider.IsSupported=false -p System.Text.Encoding.EnableUnsafeUTF7Encoding=false -p System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault=false -p System.Threading.Thread.EnableAutoreleasePool=false UnsafeAccessorsTests.dll ''
Running Verify_CallDefaultCtorClass
Running Verify_CallCtorClass
Running Verify_CallCtorValue
Running Verify_CallCtorWithEmptyNotNullName
Running Verify_CallCtorAsMethod
Running Verify_CallCtorAsMethodValue
Running Verify_AccessStaticFieldClass
Running Verify_AccessFieldClass
Running Verify_AccessStaticFieldValue
Running Verify_AccessFieldValue
Running Verify_AccessStaticMethodClass
Running Verify_AccessMethodClass
Running Verify_AccessStaticMethodVoidClass
Running Verify_AccessMethodVoidClass
Running Verify_AccessStaticMethodValue
Running Verify_AccessMethodValue
Running Verify_IgnoreCustomModifier
Running Verify_PreciseMatchCustomModifier
Running Verify_UnmanagedCallConvBitAreTreatedAsCustomModifiersAndIgnored
Running Verify_ManagedUnmanagedFunctionPointersDontMatch
Running Verify_InheritanceMethodResolution
Running Verify_InheritanceFieldResolution
Running Verify_InvalidTargetUnsafeAccessor
Running Verify_InvalidTargetUnsafeAccessorAmbiguousMatch
Running Verify_InvalidUseUnsafeAccessor
Xunit.Sdk.ThrowsException: Assert.Throws() Failure
Expected: typeof(System.BadImageFormatException)
Actual:   typeof(System.ExecutionEngineException): Attempting to JIT compile method '(wrapper other) string UnsafeAccessorsTests/Invalid:CallToString (string)' while running in aot-only mode. See https://docs.microsoft.com/xamarin/ios/internals/limitations for more information.
          
   at UnsafeAccessorsTests.<>c.<Verify_InvalidUseUnsafeAccessor>b__41_13()
   at Xunit.Assert.RecordException(Func`1 testCode)
Expected: 100
Actual: 101
END EXECUTION - FAILED
Test failed. Trying to see if dump file was created in /home/helixbot/dotnetbuild/dumps since 9/29/2023 7:23:18 PM
Test Harness Exitcode is : 1

TieredVtableMethodTests.dll

BEGIN EXECUTION
/datadisks/disk1/work/A41708E9/p/corerun -p Microsoft.Extensions.DependencyInjection.VerifyOpenGenericServiceTrimmability=true -p System.ComponentModel.TypeConverter.EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization=false -p System.Reflection.Metadata.MetadataUpdater.IsSupported=false -p System.Resources.ResourceManager.AllowCustomResourceTypes=false -p System.Runtime.InteropServices.BuiltInComInterop.IsSupported=false -p System.Runtime.InteropServices.EnableConsumingManagedCodeFromNativeHosting=false -p System.Runtime.InteropServices.EnableCppCLIHostActivation=false -p System.Runtime.InteropServices.Marshalling.EnableGeneratedComInterfaceComImportInterop=false -p System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization=true -p System.StartupHookProvider.IsSupported=false -p System.Text.Encoding.EnableUnsafeUTF7Encoding=false -p System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault=false -p System.Threading.Thread.EnableAutoreleasePool=false TieredVtableMethodTests.dll ''
Expected: 100
Actual: 1
END EXECUTION - FAILED
Test failed. Trying to see if dump file was created in /home/helixbot/dotnetbuild/dumps since 9/29/2023 7:23:22 PM
Test Harness Exitcode is : 1

varargsupport.dll and varargsupport_r.dll

BEGIN EXECUTION
/datadisks/disk1/work/A41708E9/p/corerun -p Microsoft.Extensions.DependencyInjection.VerifyOpenGenericServiceTrimmability=true -p System.ComponentModel.TypeConverter.EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization=false -p System.Reflection.Metadata.MetadataUpdater.IsSupported=false -p System.Resources.ResourceManager.AllowCustomResourceTypes=false -p System.Runtime.InteropServices.BuiltInComInterop.IsSupported=false -p System.Runtime.InteropServices.EnableConsumingManagedCodeFromNativeHosting=false -p System.Runtime.InteropServices.EnableCppCLIHostActivation=false -p System.Runtime.InteropServices.Marshalling.EnableGeneratedComInterfaceComImportInterop=false -p System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization=true -p System.StartupHookProvider.IsSupported=false -p System.Text.Encoding.EnableUnsafeUTF7Encoding=false -p System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault=false -p System.Threading.Thread.EnableAutoreleasePool=false varargsupport_r.dll ''
Test failed as InvalidProgramException was not raised.
Expected: 100
Actual: 1
END EXECUTION - FAILED
Test failed. Trying to see if dump file was created in /home/helixbot/dotnetbuild/dumps since 9/29/2023 7:23:18 PM
Test Harness Exitcode is : 1
@kotlarmilos kotlarmilos added disabled-test The test is disabled in source code against the issue area-Codegen-AOT-mono labels Oct 2, 2023
@kotlarmilos kotlarmilos added this to the 9.0.0 milestone Oct 2, 2023
@kotlarmilos kotlarmilos self-assigned this Oct 2, 2023
@kotlarmilos kotlarmilos modified the milestones: 9.0.0, Future Feb 9, 2024
@dotnet-policy-service dotnet-policy-service bot added the in-pr There is an active PR which will close this issue when it is merged label May 6, 2024
Ruihan-Yin pushed a commit to Ruihan-Yin/runtime that referenced this issue May 30, 2024
1. Adds support for compiling generic wrapper methods to Mono.  In some situations we need to emit a wrapper method that is generic.  This makes the MethodBuilder infrastructure support that.
2. Adds support for inflating generic wrapper data.  Wrappers have pointer data associated with them that is used by the code generator (For example instead of emitting field tokens, we record the `MonoClassField*` directly and then emit a fake token that is just the index of the `MonoClassField*` in the `MonoMethodWrapper:method_data` array).  The pointer data associated with a wrapper is normally just consumed verbatim.  But if the wrapper is part of a generic class, or if the wrapper is a generic method, the wrapper data might have generic parameters (for example it might be a MonoClassField for `MyList<T>` instead of `MyList<string>`).  Add support for tagging the data with its kind and inflating it if the wrapper method is inflated.
3. Applies (1) and (2) to unsafe accessor methods - the unsafe accesor wrapper generation now always tries to get the generic definition and to generate a wrapper for that generic definition and then inflate it.
4. Some AOT changes so that FullAOT substitutes lookups for an unsafe accessor by lookups for the wrapper.  Including if the unsafe accessor or wrapper is generic.  This also enabled gshared and gsharedvt for unsafe accessor wrappers.  This also fixes dotnet#92883


Contributes to dotnet#99830, dotnet#89439

**NOT DONE**
- We don't check constraints on the generic target types yet

---


* always AOT wrappers, even for generics, not the actual accessor

* add generic wrapper methods

* use generic method owner caches

* lookup unsafe accessor wrapper instances in aot-runtime

   if someone needs the unsafe accessor, lookup the wrapper instead.

   Needed when there's a call for extra instances

* cleanup marshaling - dont' use ctx as a flag

* handle some generic field accessors

   As long as the target is just some type that mentions a generic field, we're ok - the regular gsharing ldflda works. 
 It just can't be a type variable.

* issues.targets: enable some unsafe accessor AOT tests

* [metadata] add ability to inflate wrapper data

   When we create generic wrappers (or wrappers in a generic class), if the wrapper data needs to refer to a field, method, or parameter type of the definition, that data might need to be inflated if the containing class is inflated (or the generic wrapper method is inflated).

   Add a new function to opt into inflation:

   ```c
       get_marshal_cb ()->mb_inflate_wrapper_data (mb);
   ```

   Add a new function to be called after mono_mb_emit_op (or any other call that calls mono_mb_add_data):

   ```c
       mono_mb_emit_op (mb, CEE_LDFLDA, field);
       mono_mb_set_wrapper_data_kind (mb, MONO_MB_ILGEN_WRAPPER_DATA_FIELD);
   ```

   Note: mono_mb_set_wrapper_data_kind asserts if you haven't called mb_inflate_wrapper_data.

   TODO: add more wrapper data kinds for MonoMethod* and MonoClass* etc

* [marshal] refactor unsafe accessor; opt into inflate_wrapper_data

   Try to separate the ideas of "the call to the UnsafeAccessor method was inflated, so we need to inflate the wrapper" and "the UnsafeAccessor method is a generic method definition, so the wrapper should be a generic method definition, too"

* inflate MonoMethod wrapper data; impl ctor generic unsafe accessors

* fix windows build

* [aot] handle case of partial generic sharing for unsafe accessor

   In partial generic sharing, a call to an instance like `Foo<int>` is replaced by `Foo<T_INT>` where T is constrained to `int` and enums that use `int` as a base type.

   In that case the AOT compiler will emit the unsafe accessor wrapper instantiated with `T_INT`.  So in the AOT lookup we have to find calls to `UnsafeAccessor<int>` and replace them with calls to `(wrapper)
UnsafeAccessor<T_INT>` to match what the AOT compiler is doing

* [aot] for unsafe accessor wrappers with no name, record a length 0

   This is needed because for inflated unsafe accessors we write the inflated bit after the name.  So if we're accessing a constructor and we didn't record a name in the AOT image, we would erroneously read
the inflated bit as the name length.

* [aot-runtime] try to fix gsharedvt lookup

* better comments; remove fied FIXMEs

* update HelloWorld sample to support either normal AOT or FullAOT

* rename helper methods

* apply suggestions from code review

* DRY. compute inflate_generic_data in one place

* Just do one loop for inflating generic wrapper data

* better comments

* DRY. move common AOT code to mini.c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Codegen-AOT-mono disabled-test The test is disabled in source code against the issue in-pr There is an active PR which will close this issue when it is merged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant