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
ILLinker corrupts exception handler ranges for method #1507
Comments
cc @marek-safar Causes release blocking issue dotnet/runtime#42628 |
I have narrowed down a repro that produces the issue even outside of brower-wasm: <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<PublishTrimmed>true</PublishTrimmed>
<TrimMode>link</TrimMode>
<EventSourceSupport>false</EventSourceSupport>
</PropertyGroup>
</Project> using System;
using System.Threading.Tasks;
using System.Net.Http;
namespace LinkerEHBug
{
class Program
{
static async Task Main(string[] args)
{
var http = new HttpClient();
var value = await http.GetStringAsync("http://www.msn.com");
Console.WriteLine(value);
}
}
}
I found that removing |
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 |
cc @kg |
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 |
Simple repro using System;
class X
{
public static void Main ()
{
Test ();
}
static bool P => true;
static void Test ()
{
try {
if (!P)
M ();
M ();
} catch when (Log ()) {
}
}
static bool Log ()
{
return false;
}
static void M ()
{
}
} |
Fixes dotnet/linker#1507 Commit migrated from dotnet/linker@337f0c5
Steps to reproduce:
System.Net.Http.dll
, look for method<GetStringAsyncCore>d__41 MoveNext ()
. The EH clause ranges for the method are correctSystem.Net.Http.dll
, look for same method as before and notice the clause ranges have been corrupted.As part for publishing,
_RunILLink
is ran. This goes over the assemblies from the sdk, which are correct, and outputs them in theobj\Release\net5.0\linked\
folder. At this moment the method is corrupted. The linker seems to run as follows : https://gist.github.com/BrzVlad/e0f358c9d096c5acef745a1c49aae8d1While I haven't tried building the project from linux with dotnet command, the behavior should be the same.
The text was updated successfully, but these errors were encountered: