Skip to content

Commit d3572f1

Browse files
committed
Fixed a problem with finally only try block while having exception
1 parent 7731a38 commit d3572f1

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

ILRuntime/Runtime/Intepreter/ILIntepreter.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4723,6 +4723,17 @@ public object Run(ILMethod method, object instance, object[] p)
47234723
eh = GetCorrespondingExceptionHandler(ehs, null, addr, ExceptionHandlerType.Finally, false);
47244724
if(eh != null)
47254725
{
4726+
//Clear call stack
4727+
while (stack.Frames.Peek().BasePointer != frame.BasePointer)
4728+
{
4729+
var f = stack.Frames.Peek();
4730+
esp = stack.PopFrame(ref f, esp);
4731+
if (f.Method.ReturnType != AppDomain.VoidType)
4732+
{
4733+
Free(esp - 1);
4734+
esp--;
4735+
}
4736+
}
47264737
unhandledException = false;
47274738
finallyEndAddress = -1;
47284739
lastCaughtEx = ex is ILRuntimeException ? ex : new ILRuntimeException(ex.Message, this, method, oriESP, ex);

ILRuntime/Runtime/Intepreter/RegisterVM/ILIntepreter.Register.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5376,6 +5376,17 @@ public unsafe partial class ILIntepreter
53765376
eh = GetCorrespondingExceptionHandler(ehs, null, addr, ExceptionHandlerType.Finally, false);
53775377
if (eh != null)
53785378
{
5379+
//Clear call stack
5380+
while (stack.Frames.Peek().BasePointer != frame.BasePointer)
5381+
{
5382+
var f = stack.Frames.Peek();
5383+
esp = stack.PopFrame(ref f, esp);
5384+
if (f.Method.ReturnType != AppDomain.VoidType)
5385+
{
5386+
Free(esp - 1);
5387+
esp--;
5388+
}
5389+
}
53795390
unhandledException = false;
53805391
finallyEndAddress = -1;
53815392
lastCaughtEx = ex is ILRuntimeException ? ex : new ILRuntimeException(ex.Message, this, method, oriESP, ex);

0 commit comments

Comments
 (0)