From f20d0f33b88acd1442182f9c7d6ce9597e2a9f09 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Wed, 2 Mar 2022 10:59:05 -0800 Subject: [PATCH] Fixing the mono interp to assign locals as gint32 --- src/mono/mono/mini/interp/interp.c | 32 ++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/mono/mono/mini/interp/interp.c b/src/mono/mono/mini/interp/interp.c index 62027cf8a501d..9e8388076c203 100644 --- a/src/mono/mono/mini/interp/interp.c +++ b/src/mono/mono/mini/interp/interp.c @@ -6227,15 +6227,19 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK; } MINT_IN_CASE(MINT_CONV_OVF_I2_R4) { float val = LOCAL_VAR (ip [2], float); - if (!mono_try_trunc_i2 (val, (gint16*)(locals + ip [1]))) + gint16 res; + if (!mono_try_trunc_i2 (val, &res)) THROW_EX (interp_get_exception_overflow (frame, ip), ip); + LOCAL_VAR (ip [1], gint32) = res; ip += 3; MINT_IN_BREAK; } MINT_IN_CASE(MINT_CONV_OVF_I2_R8) { double val = LOCAL_VAR (ip [2], double); - if (!mono_try_trunc_i2 (val, (gint16*)(locals + ip [1]))) + gint16 res; + if (!mono_try_trunc_i2 (val, &res)) THROW_EX (interp_get_exception_overflow (frame, ip), ip); + LOCAL_VAR (ip [1], gint32) = res; ip += 3; MINT_IN_BREAK; } @@ -6257,15 +6261,19 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK; } MINT_IN_CASE(MINT_CONV_OVF_U2_R4) { float val = LOCAL_VAR (ip [2], float); - if (!mono_try_trunc_u2 (val, (guint16*)(locals + ip [1]))) + guint16 res; + if (!mono_try_trunc_u2 (val, &res)) THROW_EX (interp_get_exception_overflow (frame, ip), ip); + LOCAL_VAR (ip [1], gint32) = res; ip += 3; MINT_IN_BREAK; } MINT_IN_CASE(MINT_CONV_OVF_U2_R8) { double val = LOCAL_VAR (ip [2], double); - if (!mono_try_trunc_u2 (val, (guint16*)(locals + ip [1]))) + guint16 res; + if (!mono_try_trunc_u2 (val, &res)) THROW_EX (interp_get_exception_overflow (frame, ip), ip); + LOCAL_VAR (ip [1], gint32) = res; ip += 3; MINT_IN_BREAK; } @@ -6303,15 +6311,19 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK; } MINT_IN_CASE(MINT_CONV_OVF_I1_R4) { float val = LOCAL_VAR (ip [2], float); - if (!mono_try_trunc_i1 (val, (gint8*)(locals + ip [1]))) + gint8 res; + if (!mono_try_trunc_i1 (val, &res)) THROW_EX (interp_get_exception_overflow (frame, ip), ip); + LOCAL_VAR (ip [1], gint32) = res; ip += 3; MINT_IN_BREAK; } MINT_IN_CASE(MINT_CONV_OVF_I1_R8) { double val = LOCAL_VAR (ip [2], double); - if (!mono_try_trunc_i1 (val, (gint8*)(locals + ip [1]))) + gint8 res; + if (!mono_try_trunc_i1 (val, &res)) THROW_EX (interp_get_exception_overflow (frame, ip), ip); + LOCAL_VAR (ip [1], gint32) = res; ip += 3; MINT_IN_BREAK; } @@ -6333,15 +6345,19 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK; } MINT_IN_CASE(MINT_CONV_OVF_U1_R4) { float val = LOCAL_VAR (ip [2], float); - if (!mono_try_trunc_u1 (val, (guint8*)(locals + ip [1]))) + guint8 res; + if (!mono_try_trunc_u1 (val, &res)) THROW_EX (interp_get_exception_overflow (frame, ip), ip); + LOCAL_VAR (ip [1], gint32) = res; ip += 3; MINT_IN_BREAK; } MINT_IN_CASE(MINT_CONV_OVF_U1_R8) { double val = LOCAL_VAR (ip [2], double); - if (!mono_try_trunc_u1 (val, (guint8*)(locals + ip [1]))) + guint8 res; + if (!mono_try_trunc_u1 (val, &res)) THROW_EX (interp_get_exception_overflow (frame, ip), ip); + LOCAL_VAR (ip [1], gint32) = res; ip += 3; MINT_IN_BREAK; }