You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 25, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Sep 25, 2026. It is now read-only.
ILLinker corrupts exception handler ranges for method #1507
Go to binaries folder, disassemble System.Net.Http.dll, look for method <GetStringAsyncCore>d__41 MoveNext (). The EH clause ranges for the method are correct
Publish the same project (folder publish). Go to binaries folder, disassemble System.Net.Http.dll, look for same method as before and notice the clause ranges have been corrupted.
dotnet.exe publish -c Release -r win-x64 the above application, and run it. I get:
❯ .\bin\Release\net5.0\win-x64\publish\LinkerEHBug.exe
Unhandled exception. System.InvalidProgramException: Common Language Runtime detected an invalid program.
at System.Net.Http.HttpClient.GetStringAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.Net.Http.HttpClient.GetStringAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.GetStringAsync(Uri requestUri, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.GetStringAsync(Uri requestUri)
at System.Net.Http.HttpClient.GetStringAsync(String requestUri)
at LinkerEHBug.Program.Main(String[] args) in F:\DotNetTest\LinkerEHBug\Program.cs:line 12
at LinkerEHBug.Program.<Main>(String[] args)
I found that removing <EventSourceSupport>false</EventSourceSupport> allows the program to work properly. This property is set automatically for Blazor WASM apps, which is why it was repro'ing in Blazor by default.
The bug will be most likely in the substitution implementation for exception blocks with filters. This does not look like a regression on linker side but more like a bug exposed by changes in libraries
Activity
BrzVlad commentedon Sep 25, 2020
cc @marek-safar
Causes release blocking issue dotnet/runtime#42628
[-]ILLinker corrupts exception ranges for method[/-][+]ILLinker corrupts exception handler ranges for method[/+]eerhardt commentedon Sep 25, 2020
I have narrowed down a repro that produces the issue even outside of brower-wasm:
dotnet.exe publish -c Release -r win-x64the above application, and run it. I get:I found that removing
<EventSourceSupport>false</EventSourceSupport>allows the program to work properly. This property is set automatically for Blazor WASM apps, which is why it was repro'ing in Blazor by default.cc @vitek-karas @MichalStrehovsky
marek-safar commentedon Sep 25, 2020
The bug will be most likely in the substitution implementation for exception blocks with filters. This does not look like a regression on linker side but more like a bug exposed by changes in libraries
lewing commentedon Sep 25, 2020
cc @kg
eerhardt commentedon Sep 25, 2020
I think this change to HttpClient.GetStringAsyncCore in the libraries is exposing this linker bug - dotnet/runtime@6b1b038#diff-256c040533e94c4e518e0453c5a7d4a0R176
An extra try-catch-finally was added to that method:
With
EventSourceSupport=false, it looks like that newfinallymay be empty sinceHttpTelemetry.Log.IsEnable()will returnfalse.marek-safar commentedon Sep 25, 2020
Simple repro
Process also exception filters when marking unreachable blocks
Process also exception filters when marking unreachable blocks
Process also exception filters when marking unreachable blocks
Process also exception filters when marking unreachable blocks
Process also exception filters when marking unreachable blocks
Process also exception filters when marking unreachable blocks
Process also exception filters when marking unreachable blocks
Process also exception filters when marking unreachable blocks