runtime icon indicating copy to clipboard operation
runtime copied to clipboard

[RyuJIT/ARM32] CoreMangLib/cti/system/convert/ConvertToString failed

Open hseok-oh opened this issue 9 years ago • 4 comments

Failed on release build (success on checked build)

tests

CoreMangLib/cti/system/convert/ConvertToString7/ConvertToString7.sh
CoreMangLib/cti/system/convert/ConvertToString8/ConvertToString8.sh
FAILED   - [   0]CoreMangLib/cti/system/convert/ConvertToString7/ConvertToString7.sh
               BEGIN EXECUTION
               /nfs/rbp3/test/coreoverlay_release_arm/corerun ConvertToString7.exe
               Beginning test case for method: Convert.ToString(System.DateTime) at 8/2/1717 10:27:34 AM
               Random seed: 20010415; set environment variable CORECLR_SEED to this value to repro

               [Positive]
               Beginning scenario: PosTest1: Verify the DateTime is now...
               ERROR!!!-001 TestId-P001: value is not 8/2/17 10:27:36 AM as expected: Actual is 8/2/1717 10:27:36 AM
               Beginning scenario: PosTest2: Verify DateTime instance is MinSupportedDateTime
               Beginning scenario: PosTest3: Verify DateTime instance is MaxSupportedDateTime

               Ending test case at 8/2/1717 10:27:36 AM
               FAIL
               Expected: 100
               Actual: 0
               END EXECUTION - FAILED
FAILED   - [   1]CoreMangLib/cti/system/convert/ConvertToString8/ConvertToString8.sh
               BEGIN EXECUTION
               /nfs/rbp3/test/coreoverlay_release_arm/corerun ConvertToString8.exe
               Beginning test case for method: Convert.ToString(System.DateTime,System.IFormatProvider) at 8/2/1717 10:27:34 AM
               Random seed: 20010415; set environment variable CORECLR_SEED to this value to repro

               [Positive]
               Beginning scenario: PosTest1: Verify the DateTime is now and IFormatProvider is en-US CultureInfo...
               Beginning scenario: PosTest2: Verify the DateTime is now and IFormatProvider is fr-FR CultureInfo...
               ERROR!!!-003 TestId-P002:
                IFormatProvider is fr-FR CultureInfo.
               Beginning scenario: PosTest4: Verify DateTime instance is created by ctor(int year,int month,int day,int hour,int minute,int second) and IFormatProvider is ru-RU CultureInfo......
               Beginning scenario: PosTest5: Verify DateTime instance is created by ctor(int year,int month,int day,int hour,int minute,int second) and IFormatProvider is a null reference...
               ERROR!!!-007 TestId-P005:
                IFormatProvider is a null reference.

               Ending test case at 8/2/1717 10:27:36 AM
               FAIL
               Expected: 100
               Actual: 0
               END EXECUTION - FAILED

These tests seem similar failure

CoreMangLib/cti/system/string/StringConcat2/StringConcat2.sh
CoreMangLib/cti/system/string/StringConcat3/StringConcat3.sh
CoreMangLib/cti/system/string/StringConcat4/StringConcat4.sh
Failure messages
FAILED   - [   2]CoreMangLib/cti/system/string/StringConcat2/StringConcat2.sh
               BEGIN EXECUTION
               /nfs/rbp3/test/coreoverlay_release_arm/corerun StringConcat2.exe
               Beginning test case StringConcat2 at 8/2/1717 10:27:34 AM
               Random seed: 20010415; set environment variable CORECLR_SEED to this value to repro

               [Positive]
               Beginning scenario: PostTest1:Concat two objects of object
               Beginning scenario: PostTest2:Concat null object and null object
               Beginning scenario: PosTest3:Concat null object and empty
               Beginning scenario: PosTest4: Concat null and two tabs
               Beginning scenario: PosTest5:Concat null and an object of int
               Beginning scenario: PosTest6: Concat null and an object of datetime
               ERROR!!!-011: Concat null and an object of datetime ExpectResult is equel1/1/01 12:00:00 AM,ActualResult is (1/1/11 12:00:00 AM)
               Beginning scenario: PosTest7: Concat null and an object of bool
               Beginning scenario: PosTest8:Concat null and an object of random class instance
               Beginning scenario: PosTest9: Concat  null and an object of Guid
               Beginning scenario: PosTest10:Concat null and an object of Random
               Beginning scenario: PosTest11:Concat an object and null
               Beginning scenario: PosTest12:Concat an object of Guid and null
               Beginning scenario: PosTest13:Concat an object of Guid and an object
               Beginning scenario: PosTest14:Concat an objec and an object of datetime
               Beginning scenario: PosTest15:Concat an object of datetime and an object of bool
               Beginning scenario: PosTest16:Concat object of two number of less than 0

               Ending test case at 8/2/1717 10:27:36 AM
               FAIL
               Expected: 100
               Actual: 0
               END EXECUTION - FAILED
FAILED   - [   3]CoreMangLib/cti/system/string/StringConcat3/StringConcat3.sh
               BEGIN EXECUTION
               /nfs/rbp3/test/coreoverlay_release_arm/corerun StringConcat3.exe
               Beginning test case StringConcat3 at 8/2/1717 10:27:35 AM
               Random seed: 20010415; set environment variable CORECLR_SEED to this value to repro
               
               [Positive]
               Beginning scenario: PostTest1:Concat three objects of object
               Beginning scenario: PostTest2:Concat  three null objects
               Beginning scenario: PosTest3:Concat two null objects and a number of less than 0
               Beginning scenario: PosTest4: Concat three special strings
               Beginning scenario: PosTest5:Concat three numbers of less than 0
               Beginning scenario: PosTest6: Concat two nulls and an object of datetime
               Beginning scenario: PosTest7: Concat null and an object of datetime and one space
               ERROR!!!-013: Concat null and an object of datetime and one space ExpectResult is equel1/1/01 12:00:00 AM ,ActualResult is (1/1/11 12:00:00 AM )
               Beginning scenario: PosTest8:Concat null and an object of random class instance and bool object
               Beginning scenario: PosTest9: Concat int and special symbol and an object of Guid
               Beginning scenario: PosTest10:Concat two guids with a
                string in middle
               Beginning scenario: PosTest11:Concat three guids
               Beginning scenario: PosTest11:Concat guid,datetime and bool

               Ending test case at 8/2/1717 10:27:36 AM
               FAIL
               Expected: 100
               Actual: 0
               END EXECUTION - FAILED
FAILED   - [   4]CoreMangLib/cti/system/string/StringConcat4/StringConcat4.sh
               BEGIN EXECUTION
               /nfs/rbp3/test/coreoverlay_release_arm/corerun StringConcat4.exe
               Beginning test case StringConcat4 at 8/2/1717 10:27:35 AM
               Random seed: 20010415; set environment variable CORECLR_SEED to this value to repro

               [Positive]
               Beginning scenario: PostTest1:Concat object Array with all null member
               Beginning scenario: PostTest2:Concat object Array with empty member
               Beginning scenario: PosTest3:Concat object Array with null and empty member
               Beginning scenario: PosTest4: Concat object Array with null,empty and space member
               Beginning scenario: PosTest5:Concat object Array with int,datetime,bool and class instance member
               ERROR!!!-009: Concat an object of int ExpectResult is equel-1231/1/11 12:00:00 AMFalseStringConcat4 ,ActualResult is (-1231/1/01 12:00:00 AMFalseStringConcat4)
               Beginning scenario: PosTest6: Concat object Array with guid and some special symbols member
               Beginning scenario: PosTest7: Concat object Array with some strings and symbols member
               Beginning scenario: PosTest8:Concat object Array with bool and some strings member
               [Negative]
               Beginning scenario: NegTest1: Concat object Array is null
               Beginning scenario: NegTest2: Concat object Array with many strings

               Ending test case at 8/2/1717 10:27:49 AM
               FAIL
               Expected: 100
               Actual: 0

cc/ @dotnet/arm32-contrib

hseok-oh avatar Aug 02 '17 01:08 hseok-oh

Please assign this to me.

hseok-oh avatar Aug 02 '17 03:08 hseok-oh

@hseok-oh Can you please look into dotnet/coreclr#13184 also ? Can it be a related issue ?

hqueue avatar Aug 03 '17 00:08 hqueue

Example

using System;
using System.Globalization;

namespace ConvertToString
{
    public class ConvertToString7
    {   
        public static int Main()
        {   
            DateTime dt = DateTime.Now;
            String actualValue = dt.ToString();

            try
            {   
                String resValue = Convert.ToString(dt);
                Console.WriteLine(resValue);
                if (actualValue != resValue)
                {   
                    Console.WriteLine(actualValue);
                    return 0;
                }

            }
            catch (Exception e)
            {   
                return 0;
            }

            return 100;
        }
    }
}

Checked build result

hseok82@hseok82-rbp3:/nfs/rbp3/test/coreoverlay_checked_arm$ ./corerun /nfs/rbp3/toy/ConvertToString/bin/Release/netcoreapp2.0/ConvertToString.dll
8/2/1717 12:47:39 PM
8/2/1717 12:47:39 PM

Simplify When JIT compiling System.Globalization.DateTimeFormat.FormatCustomized(DateTime dateTime, String format, DateTimeFormatInfo dtfi, TimeSpan offset)` and called methods to print year only.

        private static String FormatCustomized(DateTime dateTime, String format, DateTimeFormatInfo dtfi, TimeSpan offset)
        {   
            Calendar cal = dtfi.Calendar;
            StringBuilder result = StringBuilderCache.Acquire();                            

            int i = 0;
            int tokenLen, hour12;

            while (i < format.Length)
            {
                char ch = format[i];
                int nextChar;
                switch (ch)
                {
                    case 'h':
                        tokenLen = 1;
                        break;
                    case 'm':
                        tokenLen = 2;
                        break;
                    case 's':
                        tokenLen = 2;
                        break;
                    case 't':
                        tokenLen = 2;
                        break;
                    case 'd':
                        tokenLen = 1;
                        break;
                    case 'M':
                        tokenLen = ParseRepeatPattern(format, i, ch);
                        break;
                    case 'y':
                        int year = cal.GetYear(dateTime);
                        tokenLen = ParseRepeatPattern(format, i, ch);
                        FormatDigits(result, year % 100, tokenLen);
                        break;
                    case '%':
                        nextChar = ParseNextChar(format, i);
                        tokenLen = 2;
                        if (nextChar >= 0 && nextChar != (int)'%')
                        {   
                            result.Append(FormatCustomized(dateTime, ((char)nextChar).ToString(), dtfi, offset));
                        }
                        break;
                    case '\\':
                        tokenLen = 2;
                        break;
                    default:
                        tokenLen = 1;
                        break;

                }
                i += tokenLen;
            }
            return StringBuilderCache.GetStringAndRelease(result);
        }

        internal static void FormatDigits(StringBuilder outputBuffer, int value, int len)
        {
            FormatDigits(outputBuffer, value, len, false);
        }

        public Calendar Calendar
        {   
            get
            {
                return (this.calendar);
            }

Example run result

hseok82@hseok82-rbp3:/nfs/rbp3/test/coreoverlay_checked_arm$ ./corerun /nfs/rbp3/toy/ConvertToString/bin/Release/netcoreapp2.0/ConvertToString.dll
1717
1717

hseok-oh avatar Aug 10 '17 03:08 hseok-oh

When JIT compiling System.Globalization.DateTimeFormat.FormatCustomized(DateTime dateTime, String format, DateTimeFormatInfo dtfi, TimeSpan offset),

Resolving edge on LSRA resolving phase

RESOLVING EDGES
   BB28 top: move V09 from r1 to STK (Split)
   BB29 bottom: move V09 from r10 to STK (Join)

BB28, BB29

------------ BB28 [09E..0BF) -> BB30 (always), preds={BB16} succs={BB30}

------------ BB28 [09E..0BF) -> BB30 (always), preds={BB16} succs={BB30}

***** BB28, stmt 31
     ( 47, 42) [000089] -------------             *  STMT      void  (IL 0x09E...0x0A5)
N019 ( 47, 42) [000083] --C-G--------             |  /--*  CALLV ind int    System.Globalization.Calendar.GetYear $545
N001 (  1,  1) [000081] -------------             |  |  |  /--*  LCL_VAR   ref    V04 loc0         u:3 <l:$201, c:$240>
N003 (  1,  3) [000523] -A------R--L- this SETUP  |  |  +--*  ASG       ref    <l:$201, c:$240>
N002 (  1,  1) [000522] D------N-----             |  |  |  \--*  LCL_VAR   ref    V28 tmp15        d:3 <l:$201, c:$240>
N009 (  3,  2) [000520] -------N-----             |  |  |  /--*  LCL_VAR   long   V25 tmp12         $5c0
N010 ( 13, 11) [000521] -A---------L- arg1 SETUP  |  |  +--*  ASG       long   $VN.Void
N008 (  6,  5) [000519] *------N-----             |  |  |  \--*  IND       long   $5c0     
N006 (  1,  1) [000517] -------------             |  |  |     |  /--*  CNS_INT   int    0 Fseq[_dateData] $40
N007 (  5,  5) [000518] -------N-----             |  |  |     \--*  ADD       byref  $183
N005 (  3,  3) [000515] L------------             |  |  |        \--*  ADDR      byref  $580
N004 (  3,  2) [000516] D------N-----             |  |  |           \--*  LCL_VAR   struct(AX) V27 tmp14
N012 (  1,  1) [000524] ------------- this in r0  |  |  +--*  LCL_VAR   ref    V04 loc0         u:3 (last use) <l:$201, c:$240>
N015 (  3,  5) [000533] -------------             |  |  |  /--*  FIELD_LIST void   int at offset 4 $2c3
N014 (  3,  4) [000532] -------------             |  |  |  |  \--*  LCL_FLD   int    V27 tmp14        [+4] $544
N016 (  7, 11) [000531] ------------- arg1 r2,r3  |  |  \--*  FIELD_LIST void   int at offset 0 $2c4
N013 (  3,  4) [000530] -------------             |  |     \--*  LCL_FLD   int    V27 tmp14        [+0] $543
N021 ( 47, 42) [000088] -AC-G---R----             \--*  ASG       int    $545
N020 (  1,  1) [000087] D------N-----                \--*  LCL_VAR   int    V11 loc7         d:3 $545

***** BB28, stmt 32
     (  1,  3) [000309] -------------             *  STMT      void  (IL 0x0A7...  ???)
N001 (  1,  1) [000702] -------------             |  /--*  LCL_VAR   int    V35 cse0          $300
N003 (  1,  3) [000308] -A------R----             \--*  ASG       int    $300
N002 (  1,  1) [000307] D------N-----                \--*  LCL_VAR   int    V15 tmp2         d:3 $300

***** BB28, stmt 33
     (  3,  3) [000314] -------------             *  STMT      void  (IL 0x0A7...  ???)
N002 (  1,  1) [000310] -------------             |     /--*  CNS_INT   int    1 $41
N003 (  3,  3) [000311] -------------             |  /--*  ADD       int    $350
N001 (  1,  1) [000091] -------------             |  |  \--*  LCL_VAR   int    V06 loc2         u:4 $380
N005 (  3,  3) [000313] -A------R----             \--*  ASG       int    $350
N004 (  1,  1) [000312] D------N-----                \--*  LCL_VAR   int    V16 tmp3         d:3 $350

------------ BB29 [0A7..0A8), preds={BB31} succs={BB30}

***** BB29, stmt 34
     (  3,  3) [000339] -------------             *  STMT      void  (IL 0x0A7...  ???)
N002 (  1,  1) [000335] -------------             |     /--*  CNS_INT   int    1 $41
N003 (  3,  3) [000336] -------------             |  /--*  ADD       int    $37b
N001 (  1,  1) [000334] -------------             |  |  \--*  LCL_VAR   int    V16 tmp3         u:4 (last use) $383
N005 (  3,  3) [000338] -A------R----             \--*  ASG       int    $37b
N004 (  1,  1) [000337] D------N-----                \--*  LCL_VAR   int    V16 tmp3      

Generated code for inserted node

Generating: N001 (  1,  1) [000800] ------------Z      t800 =    LCL_VAR   char   V09 loc5          r1 REG r1
IN0045:             strh    r1, [sp+0x1c]       // [V09 loc5]

.......

Generating: N001 (  1,  1) [000801] ------------Z      t801 =    LCL_VAR   char   V09 loc5          r10 REG r10
IN0056:             strh    r10, [sp+0x1c]      // [V09 loc5]

Other node(s) using V09

enerating: N457 (  9,  8) [000328] a--XG--------      t328 = *  IND       char   REG r2 <l:$375, c:$780>
                                                        Byref regs: 0004 {r2} => 0000 {}
IN005d:             ldrh    r2, [r2+8]
Generating: N459 (  1,  1) [000329] ------------z      t329 =    LCL_VAR   int    V09 loc5         u:3 r10 REG r10 <l:$344, c:$4c0>
                                                              /--*  t328   char
                                                              +--*  t329   int
Generating: N461 ( 17, 19) [000330] J--XG--N--S--      t330 = *  EQ        int    REG NA <l:$379, c:$37a>
IN005e:             ldr     r10, [sp+0x1c]      // [V09 loc5]
IN005f:             cmp     r2, r10

IN0045 and IN0056 uses strh to store V09 because type of node 800 and 801 is char. But IN005e uses ldr not ldrh because type of node 329 is int. So when we load value of V09, it can have additional trash value.

hseok-oh avatar Aug 10 '17 03:08 hseok-oh