-
Notifications
You must be signed in to change notification settings - Fork 128
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
ILLink : error IL1012: IL Trimmer has encountered an unexpected error #3129
Comments
@vitek-karas considering your cecil symbol files knowledge ;-) Could you look into this one? |
@marek-safar thanks for throwing me under the bus ;-) |
Cross linking to original issue AvaloniaUI/Avalonia#9127 (comment) |
I'm pretty sure this is a corruption in the pdb file. I tried to run it through a completely different tool Pdb2Pdb and that one also fails saying "Invalid compressed integer." which matches what I'm seeing in Cecil. I tried building it for .net 6 with 6.0 SDK, but it still fails the same way. This happens in This assembly seems to be generated from XAML (the sequence points point to a XAML file document), so probably some custom tool in Avalonia (sorry, don't really know how Avalonia works). |
FWIW, we have code in the NativeAOT compiler to catch situations like this: https://github.com/dotnet/runtime/blob/9cafe8f23295b5c7f4718eaaebee6dddc2e7dda6/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/DependencyAnalysis/MethodCodeNode.cs#L263-L269 (The referenced Roslyn bug has existed for years so there are libraries in the wild produced by Roslyn that run into this.) The Of course we would probably not want to catch an |
Avalonia has a msbuild task which uses Mono.Cecil to emit IL code (compiled XAML) to the built assembly. |
I tried, but I can't get it to work such that I can debug that task. Can somebody with some experience in it please advice how to setup the build locally so that I can get the task which writes the IL code (compiled XAML) under the debugger?
But under the debugger this does basically nothing because it doesn't find any XAML resources to process. Which is weird, since the fully compiled assembly clearly contains code generated from XAML. |
The task is located here: src/Avalonia.Build.Tasks |
@vitek-karas hi! Just noticed this issue, and I think I can help here. Avalonia indeed has a XAML compiler which transforms XML files and then generates IL code in the same assembly with help of Mono.Cecil. It also injects debug information, so it's possible to debug XAML elements generation in the IDE. After XamlX compiler has compiler its job, in Avalonia we also replace some previously emitted code, using Mono.Cecil only. The idea is to replace reflection-based file-includes between XAML files with generated type calls. This subtask was finding IL code (slightly simplified):
and replacing with:
Accidently, it was also breaking debug information on its way. It was not manually adjusted and was causing error from this thread. I have fixed this issue in my PR by moving this logic to the XamlX compiler code, so IL is emitted only once, without rewriting it after. And debug information is also inserted once by XamlX compiler and based on the final IL of the generated method. |
I suppose your fix in the Cecil, jbevain/cecil#867, could help with our IL-rewriting code. But we use stable nuget version, which is quite out of date. |
If you have any questions or need help with our code, please ask. |
Thanks a lot for the explanation - and for the offer. Closing this issue as resolve. |
Repro steps:
Change
ControlCatalog.NetCore.csproj
TFM to net7.0.dotnet publish -c Release -r win-x64 /p:PublishTrimmed=true
.NET SDK Version: 7.0.100
The text was updated successfully, but these errors were encountered: