Skip to content

Commit a9deee8

Browse files
authored
Report bad code when localloc is in a funclet (#121113)
The interpreter didn't check that localloc is not valid in funclets. Couple of coreclr tests were failing due to that. To make this work properly, I've removed marking blocks with BBClauseTry as it was not used for anything and preventing the check for code being in funclet working properly.
1 parent ab875d1 commit a9deee8

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

src/coreclr/interpreter/compiler.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2263,16 +2263,6 @@ void InterpCompiler::InitializeClauseBuildingBlocks(CORINFO_METHOD_INFO* methodI
22632263
BADCODE("Invalid handler region in EH clause");
22642264
}
22652265

2266-
// Find and mark all basic blocks that are part of the try region.
2267-
for (uint32_t j = clause.TryOffset; j < (clause.TryOffset + clause.TryLength); j++)
2268-
{
2269-
InterpBasicBlock* pBB = m_ppOffsetToBB[j];
2270-
if (pBB != NULL && pBB->clauseType == BBClauseNone)
2271-
{
2272-
pBB->clauseType = BBClauseTry;
2273-
}
2274-
}
2275-
22762266
InterpBasicBlock* pHandlerBB = GetBB(clause.HandlerOffset);
22772267

22782268
// Find and mark all basic blocks that are part of the handler region.
@@ -7488,6 +7478,11 @@ void InterpCompiler::GenerateCode(CORINFO_METHOD_INFO* methodInfo)
74887478
}
74897479
case CEE_LOCALLOC:
74907480
CHECK_STACK(1);
7481+
if (m_pCBB->clauseType != BBClauseNone)
7482+
{
7483+
// Localloc inside a funclet is not allowed
7484+
BADCODE("CEE_LOCALLOC inside funclet");
7485+
}
74917486
#if TARGET_64BIT
74927487
// Length is natural unsigned int
74937488
if (m_pStackPointer[-1].type == StackTypeI4)

src/coreclr/interpreter/compiler.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,6 @@ enum InterpBBState
293293
enum InterpBBClauseType
294294
{
295295
BBClauseNone,
296-
BBClauseTry,
297296
BBClauseCatch,
298297
BBClauseFinally,
299298
BBClauseFilter,

0 commit comments

Comments
 (0)