Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/coreclr/jit/fgbasic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3499,9 +3499,9 @@ void Compiler::fgFindBasicBlocks()

if (clause.Flags & CORINFO_EH_CLAUSE_FILTER)
{
if (clause.FilterOffset > info.compILCodeSize)
if (clause.FilterOffset >= info.compILCodeSize)
{
BADCODE("filter offset > codesize");
BADCODE("filter offset >= codesize");
}
jumpTarget->bitVectSet(clause.FilterOffset);
}
Expand Down Expand Up @@ -3723,6 +3723,10 @@ void Compiler::fgFindBasicBlocks()
if (clause.Flags & CORINFO_EH_CLAUSE_FILTER)
{
filtBB = HBtab->ebdFilter = fgLookupBB(clause.FilterOffset);
if (filtBB == nullptr)
{
BADCODE("Filter Clause is invalid");
}
filtBB->SetCatchType(BBCT_FILTER);
hndBegBB->SetCatchType(BBCT_FILTER_HANDLER);

Expand Down
1 change: 1 addition & 0 deletions src/tests/JIT/Directed/Directed_d.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<MergedWrapperProjectReference Include="coverage\importer\byrefsubbyref1.ilproj" />
<MergedWrapperProjectReference Include="coverage\importer\calli2.ilproj" />
<MergedWrapperProjectReference Include="coverage\importer\ceeillegal.ilproj" />
<MergedWrapperProjectReference Include="coverage\importer\filteroffset.ilproj" />
<MergedWrapperProjectReference Include="coverage\importer\Desktop\badendfinally_d.ilproj" />
<MergedWrapperProjectReference Include="coverage\importer\Desktop\badldsfld_d.ilproj" />
<MergedWrapperProjectReference Include="coverage\importer\Desktop\badtailcall_d.ilproj" />
Expand Down
50 changes: 50 additions & 0 deletions src/tests/JIT/Directed/coverage/importer/filteroffset.il
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

.assembly filteroffset {}
.assembly extern xunit.core {}
.assembly extern mscorlib {}

.class public auto ansi Test
{
.method public static int32 Main() cil managed
{
.custom instance void [xunit.core]Xunit.FactAttribute::.ctor() = (
01 00 00 00
)
.entrypoint
.try
{
call void Test::BadFilter()
leave.s Fail
}
catch [mscorlib]System.InvalidProgramException
{
pop
leave.s Pass
}

Pass:
ldc.i4 100
ret
Fail:
ldc.i4.0
ret
}

.method private static void BadFilter() cil managed noinlining
{
.maxstack 1

TryStart:
leave.s MethodEnd
HandlerStart:
pop
leave.s MethodEnd
MethodEnd:
ret
FilterStart:

.try TryStart to HandlerStart filter FilterStart handler HandlerStart to MethodEnd
}
}
8 changes: 8 additions & 0 deletions src/tests/JIT/Directed/coverage/importer/filteroffset.ilproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk.IL">
<PropertyGroup>
<CLRTestPriority>1</CLRTestPriority>
</PropertyGroup>
<ItemGroup>
<Compile Include="filteroffset.il" />
</ItemGroup>
</Project>
Loading