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

iOS/AOT: XmlSerializer.Deserialize throws Attempting to JIT compile method 'void Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializerContract:.ctor ()' while running in aot-only mode. #56533

Closed
rolfbjarne opened this issue Jul 29, 2021 · 4 comments · Fixed by #56604
Assignees
Labels
Milestone

Comments

@rolfbjarne
Copy link
Member

Description

Calling XmlSerializer.Deserialize ends up throwing a System.ExecutionEngineException: "Attempting to JIT compile method 'void Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializerContract:.ctor ()' while running in aot-only mode."

EXCEPTION: System.InvalidOperationException: XmlSerializeErrorDetails, 0, 0
 ---> System.ExecutionEngineException: Attempting to JIT compile method 'void Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializerContract:.ctor ()' while running in aot-only mode. See https://docs.microsoft.com/xamarin/ios/internals/limitations for more information.
   at System.Reflection.RuntimeConstructorInfo.InternalInvoke(Object , Object[] , Boolean ) in System.Private.CoreLib.dll:token 0x600269a+0x5
   Exception_EndOfInnerExceptionStack
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader , String , XmlDeserializationEvents ) in System.Private.Xml.dll:token 0x6001b05+0x10d
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader , String ) in System.Private.Xml.dll:token 0x6001b04+0x0
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader ) in System.Private.Xml.dll:token 0x6001b02+0x0
   at MySimpleApp.Program.XmlSerializationTest.Response.Deserialize(String xml) in /Users/rolf/work/maccore/main/xamarin-macios/tests/dotnet/MySimpleApp/AppDelegate.cs:line 67
   at MySimpleApp.Program.XmlSerializationTest.Bug1820_GenericList() in /Users/rolf/work/maccore/main/xamarin-macios/tests/dotnet/MySimpleApp/AppDelegate.cs:line 184
   at MySimpleApp.Program.Main(String[] args) in /Users/rolf/work/maccore/main/xamarin-macios/tests/dotnet/MySimpleApp/AppDelegate.cs:line 22

Test code: https://github.com/rolfbjarne/xamarin-macios/blob/c8014a6b6fd759159b409df19062f11b57ae8e2c/tests/dotnet/MySimpleApp/AppDelegate.cs#L21-L187

To reproduce:

  1. Download & install Xcode 13 beta 3.

  2. Clone my fork of xamarin-macios, and checkout the Bug1820_GenericList-testcase branch, and build it:

     git clone https://github.com/rolfbjarne/xamarin-macios
     git checkout Bug1820_GenericList-testcase
     cd xamarin-macios
     ./configure --enable-dotnet --enable-xamarin
     make reset
     make all -j8
     make install -j8
    
  3. Connect an iOS device

  4. Build & run the test project:

     make -C tests/dotnet/MySimpleApp/iOS run-dev
    

Configuration

6.0.100-rc.1.21377.4

Regression?

With regards to legacy Xamarin, yes.

@rolfbjarne
Copy link
Member Author

CC @steveisok

@steveisok
Copy link
Member

@MaximLipnin We probably want to set ReflectionOnly as a default for iOS, tvOS, and MacCatalyst.

internal static SerializationMode Mode { get; set; } = SerializationMode.ReflectionAsBackup;

@steveisok steveisok removed the untriaged New issue has not been triaged by the area owner label Jul 29, 2021
@steveisok steveisok added this to the 6.0.0 milestone Jul 29, 2021
@steveisok steveisok added os-ios Apple iOS os-tvos Apple tvOS os-maccatalyst MacCatalyst OS labels Jul 29, 2021
@ghost
Copy link

ghost commented Jul 29, 2021

Tagging subscribers to 'arch-ios': @steveisok, @akoeplinger
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

Calling XmlSerializer.Deserialize ends up throwing a System.ExecutionEngineException: "Attempting to JIT compile method 'void Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializerContract:.ctor ()' while running in aot-only mode."

EXCEPTION: System.InvalidOperationException: XmlSerializeErrorDetails, 0, 0
 ---> System.ExecutionEngineException: Attempting to JIT compile method 'void Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializerContract:.ctor ()' while running in aot-only mode. See https://docs.microsoft.com/xamarin/ios/internals/limitations for more information.
   at System.Reflection.RuntimeConstructorInfo.InternalInvoke(Object , Object[] , Boolean ) in System.Private.CoreLib.dll:token 0x600269a+0x5
   Exception_EndOfInnerExceptionStack
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader , String , XmlDeserializationEvents ) in System.Private.Xml.dll:token 0x6001b05+0x10d
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader , String ) in System.Private.Xml.dll:token 0x6001b04+0x0
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader ) in System.Private.Xml.dll:token 0x6001b02+0x0
   at MySimpleApp.Program.XmlSerializationTest.Response.Deserialize(String xml) in /Users/rolf/work/maccore/main/xamarin-macios/tests/dotnet/MySimpleApp/AppDelegate.cs:line 67
   at MySimpleApp.Program.XmlSerializationTest.Bug1820_GenericList() in /Users/rolf/work/maccore/main/xamarin-macios/tests/dotnet/MySimpleApp/AppDelegate.cs:line 184
   at MySimpleApp.Program.Main(String[] args) in /Users/rolf/work/maccore/main/xamarin-macios/tests/dotnet/MySimpleApp/AppDelegate.cs:line 22

Test code: https://github.com/rolfbjarne/xamarin-macios/blob/c8014a6b6fd759159b409df19062f11b57ae8e2c/tests/dotnet/MySimpleApp/AppDelegate.cs#L21-L187

To reproduce:

  1. Download & install Xcode 13 beta 3.

  2. Clone my fork of xamarin-macios, and checkout the Bug1820_GenericList-testcase branch, and build it:

     git clone https://github.com/rolfbjarne/xamarin-macios
     git checkout Bug1820_GenericList-testcase
     cd xamarin-macios
     ./configure --enable-dotnet --enable-xamarin
     make reset
     make all -j8
     make install -j8
    
  3. Connect an iOS device

  4. Build & run the test project:

     make -C tests/dotnet/MySimpleApp/iOS run-dev
    

Configuration

6.0.100-rc.1.21377.4

Regression?

With regards to legacy Xamarin, yes.

Author: rolfbjarne
Assignees: MaximLipnin
Labels:

area-Serialization, os-ios, os-maccatalyst, os-tvos

Milestone: 6.0.0

@rolfbjarne
Copy link
Member Author

This looks similar to #47114 (comment) (make the serialization mode dependent on RuntimeFeature.IsDynamicCodeSupported).

@StephenMolloy StephenMolloy self-assigned this Jul 29, 2021
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Jul 30, 2021
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Aug 3, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Sep 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
4 participants