From: Vlad Brezae Date: Thu, 9 Jan 2020 10:08:15 +0000 (+0200) Subject: [interp] Throw overflow exception when converting NaN (mono/mono#18384) X-Git-Tag: submit/tizen/20210909.063632~10331^2~5^2~34 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4895235de72570006f849723b88bf2a95bc0d09c;p=platform%2Fupstream%2Fdotnet%2Fruntime.git [interp] Throw overflow exception when converting NaN (mono/mono#18384) Fixes https://github.com/mono/mono/issues/18061 Commit migrated from https://github.com/mono/mono/commit/345550fb99a12f66054b7c1f545b4d117368c47f --- diff --git a/src/mono/mono/mini/interp/interp.c b/src/mono/mono/mini/interp/interp.c index e7257ac..49594a9 100644 --- a/src/mono/mono/mini/interp/interp.c +++ b/src/mono/mono/mini/interp/interp.c @@ -5752,13 +5752,13 @@ main_loop: ++ip; MINT_IN_BREAK; MINT_IN_CASE(MINT_CONV_OVF_I8_UN_R8) - if (sp [-1].data.f < 0 || sp [-1].data.f > G_MAXINT64) + if (sp [-1].data.f < 0 || sp [-1].data.f > G_MAXINT64 || isnan (sp [-1].data.f)) goto overflow_label; sp [-1].data.l = (gint64)sp [-1].data.f; ++ip; MINT_IN_BREAK; MINT_IN_CASE(MINT_CONV_OVF_I8_UN_R4) - if (sp [-1].data.f_r4 < 0 || sp [-1].data.f_r4 > G_MAXINT64) + if (sp [-1].data.f_r4 < 0 || sp [-1].data.f_r4 > G_MAXINT64 || isnan (sp [-1].data.f_r4)) goto overflow_label; sp [-1].data.l = (gint64)sp [-1].data.f_r4; ++ip; @@ -6052,13 +6052,13 @@ main_loop: ++ip; MINT_IN_BREAK; MINT_IN_CASE(MINT_CONV_OVF_I4_R4) - if (sp [-1].data.f_r4 < G_MININT32 || sp [-1].data.f_r4 > G_MAXINT32) + if (sp [-1].data.f_r4 < G_MININT32 || sp [-1].data.f_r4 > G_MAXINT32 || isnan (sp [-1].data.f_r4)) goto overflow_label; sp [-1].data.i = (gint32) sp [-1].data.f_r4; ++ip; MINT_IN_BREAK; MINT_IN_CASE(MINT_CONV_OVF_I4_R8) - if (sp [-1].data.f < G_MININT32 || sp [-1].data.f > G_MAXINT32) + if (sp [-1].data.f < G_MININT32 || sp [-1].data.f > G_MAXINT32 || isnan (sp [-1].data.f)) goto overflow_label; sp [-1].data.i = (gint32) sp [-1].data.f; ++ip; @@ -6075,13 +6075,13 @@ main_loop: ++ip; MINT_IN_BREAK; MINT_IN_CASE(MINT_CONV_OVF_U4_R4) - if (sp [-1].data.f_r4 < 0 || sp [-1].data.f_r4 > G_MAXUINT32) + if (sp [-1].data.f_r4 < 0 || sp [-1].data.f_r4 > G_MAXUINT32 || isnan (sp [-1].data.f_r4)) goto overflow_label; sp [-1].data.i = (guint32) sp [-1].data.f_r4; ++ip; MINT_IN_BREAK; MINT_IN_CASE(MINT_CONV_OVF_U4_R8) - if (sp [-1].data.f < 0 || sp [-1].data.f > G_MAXUINT32) + if (sp [-1].data.f < 0 || sp [-1].data.f > G_MAXUINT32 || isnan (sp [-1].data.f)) goto overflow_label; sp [-1].data.i = (guint32) sp [-1].data.f; ++ip; @@ -6109,13 +6109,13 @@ main_loop: ++ip; MINT_IN_BREAK; MINT_IN_CASE(MINT_CONV_OVF_I2_R8) - if (sp [-1].data.f < G_MININT16 || sp [-1].data.f > G_MAXINT16) + if (sp [-1].data.f < G_MININT16 || sp [-1].data.f > G_MAXINT16 || isnan (sp [-1].data.f)) goto overflow_label; sp [-1].data.i = (gint16) sp [-1].data.f; ++ip; MINT_IN_BREAK; MINT_IN_CASE(MINT_CONV_OVF_I2_UN_R8) - if (sp [-1].data.f < 0 || sp [-1].data.f > G_MAXINT16) + if (sp [-1].data.f < 0 || sp [-1].data.f > G_MAXINT16 || isnan (sp [-1].data.f)) goto overflow_label; sp [-1].data.i = (gint16) sp [-1].data.f; ++ip; @@ -6132,7 +6132,7 @@ main_loop: ++ip; MINT_IN_BREAK; MINT_IN_CASE(MINT_CONV_OVF_U2_R8) - if (sp [-1].data.f < 0 || sp [-1].data.f > G_MAXUINT16) + if (sp [-1].data.f < 0 || sp [-1].data.f > G_MAXUINT16 || isnan (sp [-1].data.f)) goto overflow_label; sp [-1].data.i = (guint16) sp [-1].data.f; ++ip; @@ -6160,13 +6160,13 @@ main_loop: ++ip; MINT_IN_BREAK; MINT_IN_CASE(MINT_CONV_OVF_I1_R8) - if (sp [-1].data.f < G_MININT8 || sp [-1].data.f > G_MAXINT8) + if (sp [-1].data.f < G_MININT8 || sp [-1].data.f > G_MAXINT8 || isnan (sp [-1].data.f)) goto overflow_label; sp [-1].data.i = (gint8) sp [-1].data.f; ++ip; MINT_IN_BREAK; MINT_IN_CASE(MINT_CONV_OVF_I1_UN_R8) - if (sp [-1].data.f < 0 || sp [-1].data.f > G_MAXINT8) + if (sp [-1].data.f < 0 || sp [-1].data.f > G_MAXINT8 || isnan (sp [-1].data.f)) goto overflow_label; sp [-1].data.i = (gint8) sp [-1].data.f; ++ip; @@ -6183,7 +6183,7 @@ main_loop: ++ip; MINT_IN_BREAK; MINT_IN_CASE(MINT_CONV_OVF_U1_R8) - if (sp [-1].data.f < 0 || sp [-1].data.f > G_MAXUINT8) + if (sp [-1].data.f < 0 || sp [-1].data.f > G_MAXUINT8 || isnan (sp [-1].data.f)) goto overflow_label; sp [-1].data.i = (guint8) sp [-1].data.f; ++ip; diff --git a/src/mono/netcore/CoreFX.issues_interpreter.rsp b/src/mono/netcore/CoreFX.issues_interpreter.rsp index fff998f..84c2af8 100644 --- a/src/mono/netcore/CoreFX.issues_interpreter.rsp +++ b/src/mono/netcore/CoreFX.issues_interpreter.rsp @@ -45,9 +45,5 @@ -nomethod System.Runtime.Serialization.Formatters.Tests.BinaryFormatterTests.* -nomethod System.Net.Sockets.Tests.SendReceiveSyncForceNonBlocking.TcpReceiveSendGetsCanceledByDispose -# https://github.com/mono/mono/issues/18061 [interpreter] Conversions.ToX(NaN) are expected to throw OverflowException --nomethod Microsoft.VisualBasic.Tests.ConversionsTests.* --nomethod Microsoft.VisualBasic.CompilerServices.Tests.IntegerTypeTests.FromString_ThrowsOverflowException - # https://github.com/mono/mono/issues/18063 [interpreter] EqualityComparer.Default.Equals doesn't work correctly -nomethod System.Collections.Generic.Tests.EqualityComparerTests.NullableEquals*