From afffab3b5c718a9241233a8c6747a3471b2171fc Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Fri, 19 May 2017 11:37:38 -0400 Subject: [PATCH] [amd64] Fix the allocation of the caller area in filter clauses. Fixes #56567. (#4903) --- mono/mini/exceptions.cs | 20 ++++++++++++++++++++ mono/mini/mini-amd64.c | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/mono/mini/exceptions.cs b/mono/mini/exceptions.cs index c7b10b3a4c1..f21ba2b5d18 100644 --- a/mono/mini/exceptions.cs +++ b/mono/mini/exceptions.cs @@ -2912,6 +2912,26 @@ class Tests // Console.WriteLine ("res2: " + res); return "outerFinally_fwos_fromFilter_2ndcatch_innerFinally_init" == res ? 1234 : 0; } + + public struct FooStruct + { + public long Part1 { get; } + public long Part2 { get; } + + public byte Part3 { get; } + } + + [MethodImpl( MethodImplOptions.NoInlining )] + private static bool ExceptionFilter( byte x, FooStruct item ) => true; + + public static int test_0_filter_caller_area () { + try { + throw new Exception(); + } + catch (Exception) when (ExceptionFilter (default(byte), default (FooStruct))) { + } + return 0; + } } #if !__MOBILE__ diff --git a/mono/mini/mini-amd64.c b/mono/mini/mini-amd64.c index decf0ef0254..2978af64ecb 100644 --- a/mono/mini/mini-amd64.c +++ b/mono/mini/mini-amd64.c @@ -4829,7 +4829,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) amd64_mov_membase_reg (code, spvar->inst_basereg, spvar->inst_offset, AMD64_RSP, sizeof(gpointer)); if ((MONO_BBLOCK_IS_IN_REGION (bb, MONO_REGION_FINALLY) || - MONO_BBLOCK_IS_IN_REGION (bb, MONO_REGION_FINALLY)) && + MONO_BBLOCK_IS_IN_REGION (bb, MONO_REGION_FILTER)) && cfg->param_area) { amd64_alu_reg_imm (code, X86_SUB, AMD64_RSP, ALIGN_TO (cfg->param_area, MONO_ARCH_FRAME_ALIGNMENT)); } -- 2.25.1