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] Runtime tests failing with 'Attempting to JIT compile method' for Mono FullAOT mode #70492

Open
3 of 4 tasks
ivanpovazan opened this issue Jun 9, 2022 · 6 comments
Open
3 of 4 tasks
Labels
area-Codegen-AOT-mono disabled-test The test is disabled in source code against the issue runtime-mono specific to the Mono runtime
Milestone

Comments

@ivanpovazan
Copy link
Member

ivanpovazan commented Jun 9, 2022

Summary

Runtime tests:

  • /JIT/Directed/callconv/PlatformDefaultMemberFunction/PlatformDefaultMemberFunctionTest/*
  • /JIT/Directed/callconv/CdeclMemberFunction/CdeclMemberFunctionTest/*
  • /JIT/Directed/callconv/StdCallMemberFunction/StdCallMemberFunctionTest/*
  • /JIT/Directed/callconv/ThisCall/ThisCallTest/*

are failing in FullAOT mode on Mono with nearly the same Attempting to JIT compile method xxx while running in aot-only mode.

StdCallMemberFunctionTest

Output

Full output for /JIT/Directed/callconv/StdCallMemberFunction/StdCallMemberFunctionTest/*:

System.ExecutionEngineException: Attempting to JIT compile method '(wrapper managed-to-native) StdCallMemberFunctionNative/SizeF modopt(System.Runtime.CompilerServices.CallConvMemberFunction) modopt(System.Runtime.CompilerServices.CallConvStdcall) StdCallMemberFunctionTest:wrapper_native_indirect_0x600003ce7140 (intptr&,StdCallMemberFunctionNative/C*,int)' while running in aot-only mode. See https://docs.microsoft.com/xamarin/ios/internals/limitations for more information.

   at StdCallMemberFunctionTest.Test8ByteHFA(C* instance) in /Users/ivan/repos/runtime-mono-AOT/src/tests/JIT/Directed/callconv/StdCallMemberFunction/StdCallMemberFunctionTest.cs:line 96
   at StdCallMemberFunctionTest.Main(String[] args)
Expected: 100
Actual: 101
END EXECUTION - FAILED

Repro

  1. Enable building the test with Mono AOT
diff --git a/src/tests/JIT/Directed/callconv/Directory.Build.props b/src/tests/JIT/Directed/callconv/Directory.Build.props
index 49b99b7a101..9ed3161df40 100644
--- a/src/tests/JIT/Directed/callconv/Directory.Build.props
+++ b/src/tests/JIT/Directed/callconv/Directory.Build.props
@@ -2,6 +2,6 @@
   <Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props, $(MSBuildThisFileDirectory)..))" />
 
   <PropertyGroup>
-    <MonoAotIncompatible>true</MonoAotIncompatible>
+    <MonoAotIncompatible>false</MonoAotIncompatible>
   </PropertyGroup>
 </Project>
  1. Build Mono
./build.sh mono+libs+clr.hosts -c debug /p:MonoEnableLlvm=true /p:MonoLLVMUseCxx11Abi=true
  1. Build the test
./src/tests/build.sh mono debug /p:LibrariesConfiguration=Debug -test:JIT/Directed/callconv/StdCallMemberFunction/StdCallMemberFunctionTest.csproj
  1. AOT compile the test
./src/tests/build.sh mono_fullaot debug /p:LibrariesConfiguration=Debug -test:JIT/Directed/callconv/StdCallMemberFunction/StdCallMemberFunctionTest.csproj
  1. Run the test (note: adjust the paths)
MONO_ENV_OPTIONS=--full-aot bash /Users/ivan/repos/runtime-mono-AOT/artifacts/tests/coreclr/OSX.arm64.Debug/JIT/Directed/callconv/StdCallMemberFunction/StdCallMemberFunctionTest/StdCallMemberFunctionTest.sh  -coreroot=/Users/ivan/repos/runtime-mono-AOT/artifacts/tests/coreclr/OSX.arm64.Debug/Tests/Core_Root

Additional notes

Tests exclusion details should be updated to reference this tracking issue: Done.

Possibly related to: #50440

cc: @lambdageek @lateralusX

@ivanpovazan ivanpovazan added area-Codegen-AOT-mono runtime-mono specific to the Mono runtime labels Jun 9, 2022
@ivanpovazan ivanpovazan added this to the Future milestone Jun 9, 2022
@ivanpovazan
Copy link
Member Author

@lambdageek should we try to fix this for .NET7?

@SamMonoRT
Copy link
Member

Assigning to @LeVladIonescu related to current work

@matouskozak
Copy link
Member

matouskozak commented Dec 15, 2023

Current situation. Mono is reporting the following warnings for StdCallMemberFunctionTest and CdeclMemberFunctionTest tests:

Multiple calling conventions are not supported for UnmanagedCallersOnlyAttribute parameter CallConvs, specified for method GetWidthAsLong. Only the first calling convention will be taken into account
Multiple calling conventions are not supported for UnmanagedCallersOnlyAttribute parameter CallConvs, specified for method GetE. Only the first calling convention will be taken into account
Multiple calling conventions are not supported for UnmanagedCallersOnlyAttribute parameter CallConvs, specified for method GetHeightAsInt. Only the first calling convention will be taken into account
Multiple calling conventions are not supported for UnmanagedCallersOnlyAttribute parameter CallConvs, specified for method GetWidth. Only the first calling convention will be taken into account
Multiple calling conventions are not supported for UnmanagedCallersOnlyAttribute parameter CallConvs, specified for method GetSize. Only the first calling convention will be taken into account

This could be related to missing support for CallConvMemberFunction #50440 as is listed in the PR description.

The ThisCallTest is still failing with:

System.ExecutionEngineException: Attempting to JIT compile method '(wrapper native-to-managed) ThisCallNative/SizeF ThisCallTest/<>c:<get_ManagedVtable>b__20_0 (ThisCallNative/C*,int)' while running in aot-only mode. See https://docs.microsoft.com/xamarin/ios/internals/limitations for more information.

   at System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(Delegate d)
   at System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate[GetSizeFn](GetSizeFn d)
   at ThisCallTest.get_ManagedVtable()
   at ThisCallTest.Test8ByteHFAReverse()
   at ThisCallTest.TestEntryPoint()
Xunit.Sdk.EqualException: Assert.Equal() Failure: Values differ
Expected: 100
Actual:   101
   at Xunit.Assert.Equal[Int32](Int32 expected, Int32 actual, IEqualityComparer`1 comparer)
   at Xunit.Assert.Equal[Int32](Int32 expected, Int32 actual)
   at __GeneratedMainWrapper.Main()
Expected: 100
Actual: 101
END EXECUTION - FAILED

and PlatformDefaultMemberFunctionTest is passing correctly.

@ivanpovazan
Copy link
Member Author

@matouskozak I suggest we enable the tests that are now passing.

@matouskozak
Copy link
Member

Enabled tests (#96243):

  • PlatformDefaultMemberFunctionTest
  • StdCallMemberFunctionTest
  • CdeclMemberFunctionTest

Test to fix:

  • ThisCallTest

@ivanpovazan
Copy link
Member Author

@matouskozak are you currently actively working on the fix for ThisCallTest?
If not, I would suggest updating the issue description with the current state and add a disabled test label.

@matouskozak matouskozak added the disabled-test The test is disabled in source code against the issue label Feb 16, 2024
@vitek-karas vitek-karas assigned steveisok and unassigned matouskozak Feb 28, 2024
@steveisok steveisok removed their assignment Jun 28, 2024
@steveisok steveisok modified the milestones: 9.0.0, Future Jun 28, 2024
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 runtime-mono specific to the Mono runtime
Projects
None yet
Development

No branches or pull requests

6 participants