diff --git a/src/coreclr/jit/fgbasic.cpp b/src/coreclr/jit/fgbasic.cpp index 02bb832c24a4f2..1b58b09a5d1b76 100644 --- a/src/coreclr/jit/fgbasic.cpp +++ b/src/coreclr/jit/fgbasic.cpp @@ -3741,24 +3741,22 @@ void Compiler::fgFindBasicBlocks() } else { - HBtab->ebdTyp = clause.ClassToken; - - /* Set bbCatchTyp as appropriate */ - + // Set ebdTyp and bbCatchTyp as appropriate + // if (clause.Flags & CORINFO_EH_CLAUSE_FINALLY) { hndBegBB->bbCatchTyp = BBCT_FINALLY; + HBtab->ebdTyp = 0; } else { if (clause.Flags & CORINFO_EH_CLAUSE_FAULT) { hndBegBB->bbCatchTyp = BBCT_FAULT; + HBtab->ebdTyp = 0; } else { - hndBegBB->bbCatchTyp = clause.ClassToken; - // These values should be non-zero value that will // not collide with real tokens for bbCatchTyp if (clause.ClassToken == 0) @@ -3766,6 +3764,9 @@ void Compiler::fgFindBasicBlocks() BADCODE("Exception catch type is Null"); } + hndBegBB->bbCatchTyp = clause.ClassToken; + HBtab->ebdTyp = clause.ClassToken; + noway_assert(clause.ClassToken != BBCT_FAULT); noway_assert(clause.ClassToken != BBCT_FINALLY); noway_assert(clause.ClassToken != BBCT_FILTER); diff --git a/src/coreclr/jit/jiteh.cpp b/src/coreclr/jit/jiteh.cpp index bf7ba8cb03bc9a..287cd28393d388 100644 --- a/src/coreclr/jit/jiteh.cpp +++ b/src/coreclr/jit/jiteh.cpp @@ -1522,6 +1522,8 @@ void Compiler::fgAllocEHTable() compHndBBtab = new (this, CMK_BasicBlock) EHblkDsc[compHndBBtabAllocCount]; + memset(compHndBBtab, 0, compHndBBtabAllocCount * sizeof(*compHndBBtab)); + compHndBBtabCount = info.compXcptnsCount; } @@ -1883,6 +1885,10 @@ EHblkDsc* Compiler::fgTryAddEHTableEntries(unsigned XTnum, unsigned count, bool EHblkDsc* newTable = new (this, CMK_BasicBlock) EHblkDsc[compHndBBtabAllocCount]; + // Zero the storage + + memset(newTable, 0, compHndBBtabAllocCount * sizeof(*compHndBBtab)); + // Move over the stuff before the new entries memcpy_s(newTable, compHndBBtabAllocCount * sizeof(*compHndBBtab), compHndBBtab, XTnum * sizeof(*compHndBBtab)); diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs index 45bfd1a2edbfee..a1dc79692155f5 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs @@ -3117,8 +3117,8 @@ private void setEHcount(uint cEH) private void setEHinfo(uint EHnumber, ref CORINFO_EH_CLAUSE clause) { - // Filters don't have class token in the clause.ClassTokenOrOffset - if ((clause.Flags & CORINFO_EH_CLAUSE_FLAGS.CORINFO_EH_CLAUSE_FILTER) == 0) + // Filters, finallys, and faults don't have class token in the clause.ClassTokenOrOffset + if ((clause.Flags & (CORINFO_EH_CLAUSE_FLAGS.CORINFO_EH_CLAUSE_FILTER | CORINFO_EH_CLAUSE_FLAGS.CORINFO_EH_CLAUSE_FINALLY | CORINFO_EH_CLAUSE_FLAGS.CORINFO_EH_CLAUSE_FAULT)) == 0) { if (clause.ClassTokenOrOffset != 0) { diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index c15c2f6f81f4fe..f7a238c5ce7373 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -12734,7 +12734,7 @@ void CEECodeGenInfo::setEHinfoWorker( LOG((LF_EH, LL_INFO1000000, " FilterOffset : 0x%08lx -> 0x%08lx\n", clause->FilterOffset, pEHClause->FilterOffset)); if (IsDynamicScope(m_MethodInfo.scope) && - ((pEHClause->Flags & COR_ILEXCEPTION_CLAUSE_FILTER) == 0) && + ((pEHClause->Flags & (COR_ILEXCEPTION_CLAUSE_FILTER | COR_ILEXCEPTION_CLAUSE_FINALLY | COR_ILEXCEPTION_CLAUSE_FAULT)) == 0) && (clause->ClassToken != mdTokenNil)) { ResolvedToken resolved{};