Unity IL2CPP Bug : IL2CPP error for method 'System.Void ::.ctor()'

Unity4.7版本在 IL2CPP 打包 IOS的时候出现错误:

Unity IL2CPP Bug : IL2CPP error for method 'System.Void ::.ctor()'_第1张图片

IL2CPP error for method 'System.Void ::.ctor()' in assembly 'C:\Users\DELL\Documents\New Unity Project 4\Temp\StagingArea\Data\Managed\UnityEngine.UI.dll'
Additional information: Build a development build for more information. Reentrant Fallback method invocation occured. It might be because either this FallbackBuffer is incorrectly shared by multiple threads, invoked inside Encoding recursively, or Reset invocation is forgotten.

stdout;
IL2CPP error for method 'System.Void ::.ctor()' in assembly 'C:\Users\DELL\Documents\New Unity Project 4\Temp\StagingArea\Data\Managed\UnityEngine.UI.dll'
Additional information: Build a development build for more information. Reentrant Fallback method invocation occured. It might be because either this FallbackBuffer is incorrectly shared by multiple threads, invoked inside Encoding recursively, or Reset invocation is forgotten.
il2cpp.exe didn't catch exception: System.ArgumentException: Reentrant Fallback method invocation occured. It might be because either this FallbackBuffer is incorrectly shared by multiple threads, invoked inside Encoding recursively, or Reset invocation is forgotten.
  at System.Text.EncoderReplacementFallbackBuffer.Fallback (Int32 index) [0x00000] in :0 
  at System.Text.EncoderReplacementFallbackBuffer.Fallback (Char charUnknown, Int32 index) [0x00000] in :0 
  at System.Text.UTF8Encoding.GetFallbackChars (System.Char* chars, System.Char* start, System.Text.EncoderFallback fallback, System.Text.EncoderFallbackBuffer& buffer) [0x00000] in :0 
  at System.Text.UTF8Encoding.InternalGetByteCount (System.Char* chars, Int32 count, System.Text.EncoderFallback fallback, System.Char& leftOver, Boolean flush) [0x00000] in :0 
  at System.Text.UTF8Encoding.GetByteCount (System.Char* chars, Int32 count) [0x00000] in :0 
  at System.Text.Encoding.GetByteCount (System.String s) [0x00000] in :0 
  at System.Text.UTF8Encoding.GetByteCount (System.String chars) [0x00000] in :0 
  at System.Text.Encoding.GetBytes (System.String s) [0x00000] in :0 
  at Unity.IL2CPP.StringLiterals.StringLiteralWriter.Write (System.IO.Stream stringLiteralStream, System.IO.Stream stringLiteralDataStream) [0x00000] in :0 
  at Unity.IL2CPP.MetadataCacheWriter.WriteMetadata (NiceIO.NPath outputDir, Unity.IL2CPP.GenericsCollection.InflatedCollection generics, Mono.Cecil.TypeDefinition[] allTypeDefinitions, ICollection`1 usedAssemblies, Unity.IL2CPP.MethodTables methodTables, Unity.IL2CPP.Metadata.MetadataCollector metadataCollector, Unity.IL2CPP.AttributeCollection attributeCollection, Unity.IL2CPP.Metadata.VTableBuilder vTableBuilder, Unity.IL2CPP.MethodCollector methodCollector) [0x00000] in :0 
  at Unity.IL2CPP.SourceWriter.WriteCollectedMetadata (Unity.IL2CPP.GenericsCollection.InflatedCollection genericsCollection, ICollection`1 usedAssemblies, NiceIO.NPath outputDir, Unity.IL2CPP.Metadata.MetadataCollector metadataCollector, Unity.IL2CPP.AttributeCollection attributeCollection, Unity.IL2CPP.Metadata.VTableBuilder vTableBuilder, Unity.IL2CPP.MethodCollector methodCollector) [0x00000] in :0 
  at Unity.IL2CPP.AssemblyConverter.Apply () [0x00000] in :0 
  at Unity.IL2CPP.AssemblyConverter.ConvertAssemblies (System.String[] assemblies, NiceIO.NPath outputDir) [0x00000] in :0 
stderr:

Unhandled Exception: System.ArgumentException: Reentrant Fallback method invocation occured. It might be because either this FallbackBuffer is incorrectly shared by multiple threads, invoked inside Encoding recursively, or Reset invocation is forgotten.

  at System.Text.EncoderReplacementFallbackBuffer.Fallback (Int32 index) [0x00000] in :0 

  at System.Text.EncoderReplacementFallbackBuffer.Fallback (Char charUnknown, Int32 index) [0x00000] in :0 

  at System.Text.UTF8Encoding.GetFallbackChars (System.Char* chars, System.Char* start, System.Text.EncoderFallback fallback, System.Text.EncoderFallbackBuffer& buffer) [0x00000] in :0 

  at System.Text.UTF8Encoding.InternalGetByteCount (System.Char* chars, Int32 count, System.Text.EncoderFallback fallback, System.Char& leftOver, Boolean flush) [0x00000] in :0 

  at System.Text.UTF8Encoding.GetByteCount (System.Char* chars, Int32 count) [0x00000] in :0 

  at System.Text.Encoding.GetByteCount (System.String s) [0x00000] in :0 

  at System.Text.UTF8Encoding.GetByteCount (System.String chars) [0x00000] in :0 

  at System.Text.Encoding.GetBytes (System.String s) [0x00000] in :0 

  at Unity.IL2CPP.StringLiterals.StringLiteralWriter.Write (System.IO.Stream stringLiteralStream, System.IO.Stream stringLiteralDataStream) [0x00000] in :0 

  at Unity.IL2CPP.MetadataCacheWriter.WriteMetadata (NiceIO.NPath outputDir, Unity.IL2CPP.GenericsCollection.InflatedCollection generics, Mono.Cecil.TypeDefinition[] allTypeDefinitions, ICollection`1 usedAssemblies, Unity.IL2CPP.MethodTables methodTables, Unity.IL2CPP.Metadata.MetadataCollector metadataCollector, Unity.IL2CPP.AttributeCollection attributeCollection, Unity.IL2CPP.Metadata.VTableBuilder vTableBuilder, Unity.IL2CPP.MethodCollector methodCollector) [0x00000] in :0 

  at Unity.IL2CPP.SourceWriter.WriteCollectedMetadata (Unity.IL2CPP.GenericsCollection.InflatedCollection genericsCollection, ICollection`1 usedAssemblies, NiceIO.NPath outputDir, Unity.IL2CPP.Metadata.MetadataCollector metadataCollector, Unity.IL2CPP.AttributeCollection attributeCollection, Unity.IL2CPP.Metadata.VTableBuilder vTableBuilder, Unity.IL2CPP.MethodCollector methodCollector) [0x00000] in :0 

  at Unity.IL2CPP.AssemblyConverter.Apply () [0x00000] in :0 

  at Unity.IL2CPP.AssemblyConverter.ConvertAssemblies (System.String[] assemblies, NiceIO.NPath outputDir) [0x00000] in :0 

UnityEngine.Debug:LogError(Object)
UnityEditorInternal.Runner:RunManagedProgram(String, String, String, CompilerOutputParserBase) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:66)
UnityEditorInternal.IL2CPPBuilder:ConvertPlayerDlltoCpp(ICollection`1, String, String) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:424)
UnityEditorInternal.IL2CPPBuilder:Run() (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:293)
UnityEditorInternal.IL2CPPUtils:RunIl2Cpp(String, String, IIl2CppPlatformProvider, Action`1, RuntimeClassRegistry) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:211)
UnityEditor.HostView:OnGUI()

Error building Player: Exception: E:\Program Files (x86)\Unity4.7.0f1\Editor\Data\il2cpp/build/il2cpp.exe did not run properly!

根据错误Log可以判断是 IL2CPP 在将C# 代码转成 CPP的时候解析出错 。 但是却没有具体的提示到底是哪里有问题!

转自http://blog.csdn.net/huutu http://www.thisisgame.com.cn

还好有SVN,在经过一晚上的各种回滚之后,找到了罪魁祸首,一个复杂的正则表达式:

string regstr = "[\uD800-\uDBFF][\uDC00-\uDFFF]|[\u2600-\u26FF][\uDE00-\uDEFF]";

就是这个正则表达式导致的 IL2CPP 崩溃。


测试发现 Unity5.3.1f1 已经解决这个Bug,但是Unity4 已经停止更新了!!

你可能感兴趣的:(Unity)