dotnet/runtime

ILVerify fails to verify some catch-to-try leave instructions

Open

#48,250 opened on Feb 12, 2021

View on GitHub
 (2 comments) (0 reactions) (1 assignee)C# (5,445 forks)batch import
Priority:3area-Tools-ILVerificationhelp wanted

Repository metrics

Stars
 (17,886 stars)
PR merge metrics
 (Avg merge 12d 11h) (661 merged PRs in 30d)

Description

Description

To reproduce: Run ILVerify on the Foo.dll assembly in this zip file. The following output should be produced:

[IL]: Error [LeaveIntoTry]: [...\Foo.dll : .A::m2(int32)][offset 0x00000014] Leave into try block.
1 Error(s) Verifying ...\Foo.dll

If the assembly is executed on .NET 5 (by invoking its Main method), it produces the expected output without any errors.

The assembly contains two static methods A.m1 and A.m2. Both contain leave instructions that jump from a catch block to its associated try block, which is legal according to ECMA-335, section I.12.4.2.8.2.8.

ILVerify correctly verifies the leave in A.m1. In A.m2, the catch block and the try block to which it jumps to are nested in another try block which has a finally block, which triggers the bug.

Configuration

ILVerify version: 5.0.0-rtm.20519.4+cf258a14b70ad9069470a108f13765e0e5988f51

Contributor guide