Skip to content

Commit 1d9c93f

Browse files
authored
JIT: tolerate malformed IL when counting block successors (#83676)
If we run synthesis, we may now invoke `BasicBlock::NumSucc` before we've detected some cases of invalid IL, In particular an endfinally that is not within a finally (this gets detected during importation). Tolerate this by reporting that an endfinally with no handler index has no successors. Fixes #83674.
1 parent eefaa5a commit 1d9c93f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/coreclr/jit/block.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,6 +1151,13 @@ unsigned BasicBlock::NumSucc(Compiler* comp)
11511151

11521152
case BBJ_EHFINALLYRET:
11531153
{
1154+
// We may call this method before we realize we have invalid IL. Tolerate.
1155+
//
1156+
if (!hasHndIndex())
1157+
{
1158+
return 0;
1159+
}
1160+
11541161
// The first block of the handler is labelled with the catch type.
11551162
BasicBlock* hndBeg = comp->fgFirstBlockOfHandler(this);
11561163
if (hndBeg->bbCatchTyp == BBCT_FINALLY)

0 commit comments

Comments
 (0)