diff --git a/src/Lua/Runtime/LuaVirtualMachine.cs b/src/Lua/Runtime/LuaVirtualMachine.cs index d0ff6ae3..5f07a447 100644 --- a/src/Lua/Runtime/LuaVirtualMachine.cs +++ b/src/Lua/Runtime/LuaVirtualMachine.cs @@ -932,16 +932,17 @@ static bool MoveNext(ref VirtualMachineExecutionContext context, out PostOperati } catch (Exception e) { - context.PopOnTopCallStackFrames(); context.State.CloseUpValues(context.Thread, context.FrameBase); LuaValueArrayPool.Return1024(context.ResultsBuffer, true); if (e is not LuaRuntimeException) { - var newException = new LuaRuntimeException(GetTracebacks(ref context), e); + var newException = new LuaRuntimeException(context.State.GetTraceback(), e); + context.PopOnTopCallStackFrames(); context = default; throw newException; } + context.PopOnTopCallStackFrames(); throw; } }