Skip to content

Starting any URI test leads to a stack overflow in System.Private.CoreLib #40073

Closed

Description

@alnikola

Description

Any attempt to run System.Private.Uri/FunctionalTests leads to a stack overflow in CoreLib and finally fails with StackOverflowException. The exception gets thrown somewhere in the application startup logic before actual test code starts executing.

Configuration

It was reproduced using the latest master on 3 different local machines running Windows 10 (confirmed on ver. 1909).
Repro steps:

  1. Checkout master
  2. Pull the latest master
  3. Clear local repo
    git clean -xfd
  4. Build coreclr in release and libraries in debug
    build clr+libs -c debug -rc release
  5. Completely build System.Private.Uri solution
    build -project src\libraries\System.Private.Uri\System.Private.Uri.sln -rc release
  6. Go to FunctionalTests folder
    cd src\libraries\System.Private.Uri\tests\FunctionalTests
  7. Run all tests
    dotnet msbuild /t:Test /p:CoreCLRConfiguration=Release

Stack trace

  Stack overflow.
  Repeat 185 times:
  --------------------------------
     at System.Array.LastIndexOf[[System.__Canon, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.__Canon[], System.__Canon, Int32, Int32)
     at System.Collections.Generic.List`1[[System.__Canon, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].LastIndexOf(System.__Canon, Int32, Int32)
     at System.Collections.Generic.List`1[[System.__Canon, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].LastIndexOf(System.__Canon)
     at System.SR.InternalGetResourceString(System.String)
     at System.SR.GetResourceString(System.String, System.String)
     at System.SR.GetResourceString(System.String)
     at System.SR.get_Arg_NullReferenceException()
     at System.NullReferenceException..ctor()
  --------------------------------
     at System.Array.LastIndexOf[[System.__Canon, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.__Canon[], System.__Canon, Int32, Int32)
     at System.Collections.Generic.List`1[[System.__Canon, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].LastIndexOf(System.__Canon, Int32, Int32)
     at System.Collections.Generic.List`1[[System.__Canon, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].LastIndexOf(System.__Canon)
     at System.SR.InternalGetResourceString(System.String)
     at System.SR.GetResourceString(System.String, System.String)
     at System.SR.GetResourceString(System.String)
     at System.SR.get_Arg_AccessViolationException()
     at System.AccessViolationException..ctor()
     at System.Runtime.CompilerServices.CastHelpers.TryGet(UIntPtr, UIntPtr)
     at System.Runtime.CompilerServices.CastHelpers.StelemRef_Helper(System.Object ByRef, Void*, System.Object)
     at System.Collections.Generic.ComparerHelpers.CreateDefaultEqualityComparer(System.Type)
     at System.Collections.Generic.EqualityComparer`1[[System.__Canon, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]..cctor()
     at System.Collections.Generic.EqualityComparer`1[[System.__Canon, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].get_Default()
     at System.Array.LastIndexOf[[System.__Canon, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.__Canon[], System.__Canon, Int32, Int32)
     at System.Collections.Generic.List`1[[System.__Canon, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].LastIndexOf(System.__Canon, Int32, Int32)
     at System.Collections.Generic.List`1[[System.__Canon, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].LastIndexOf(System.__Canon)
     at System.SR.InternalGetResourceString(System.String)
     at System.SR.GetResourceString(System.String, System.String)
     at System.SR.GetResourceString(System.String)
     at System.SR.get_Arg_AccessViolationException()
     at System.AccessViolationException..ctor()
     at System.Runtime.CompilerServices.CastHelpers.TryGet(UIntPtr, UIntPtr)
     at System.Runtime.CompilerServices.CastHelpers.StelemRef_Helper(System.Object ByRef, Void*, System.Object)
     at System.Collections.Generic.List`1[[System.__Canon, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].AddWithResize(System.__Canon)
     at System.Collections.Generic.List`1[[System.__Canon, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Add(System.__Canon)
     at System.SR.InternalGetResourceString(System.String)
     at System.SR.GetResourceString(System.String, System.String)
     at System.SR.GetResourceString(System.String)
     at System.SR.get_Arg_AccessViolationException()
     at System.AccessViolationException..ctor()
     at System.Runtime.CompilerServices.CastHelpers.TryGet(UIntPtr, UIntPtr)
     at System.Runtime.CompilerServices.CastHelpers.ChkCastAny(Void*, System.Object)
     at System.Collections.Generic.Dictionary`2[[System.__Canon, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]..ctor(Int32, System.Collections.Generic.IEqualityComparer`1<System.__Canon>)
     at System.AppContext.Setup(Char**, Char**, Int32)

Activity

  1. added this to the 5.0.0 milestone on Jul 29, 2020
  2. john-h-k commented on Jul 29, 2020

    @john-h-k
    Contributor

    @JakenVeina I believe this is the same recurring exception you were having with your stack overflow with GLFW?

  3. jkotas commented on Jul 29, 2020

    @jkotas
    Member

    Step 5. "Completely build System.Private.Uri solution" rebuilds CoreLib with a broken version.

    Before step 5 (good CoreLib):

    D:\runtime>dir D:\runtime\artifacts\bin\coreclr\Windows_NT.x64.Release\IL
     Volume in drive D has no label.
     Volume Serial Number is 9014-A74F
    
     Directory of D:\runtime\artifacts\bin\coreclr\Windows_NT.x64.Release\IL
    
    07/29/2020  06:59 AM    <DIR>          .
    07/29/2020  06:59 AM    <DIR>          ..
    07/29/2020  06:59 AM             6,452 System.Private.CoreLib.deps.json
    07/29/2020  06:59 AM         3,458,048 System.Private.CoreLib.dll
    07/29/2020  06:59 AM         4,237,531 System.Private.CoreLib.xml
                   3 File(s)      7,702,031 bytes
                   2 Dir(s)  1,438,068,240,384 bytes free
    

    After Step 5 (broken CoreLib, notice that the size is different):

    D:\runtime>dir D:\runtime\artifacts\bin\coreclr\Windows_NT.x64.Release\IL
     Volume in drive D has no label.
     Volume Serial Number is 9014-A74F
    
     Directory of D:\runtime\artifacts\bin\coreclr\Windows_NT.x64.Release\IL
    
    07/29/2020  07:02 AM    <DIR>          .
    07/29/2020  07:02 AM    <DIR>          ..
    07/29/2020  07:02 AM             6,452 System.Private.CoreLib.deps.json
    07/29/2020  07:02 AM         3,443,712 System.Private.CoreLib.dll
    07/29/2020  07:02 AM         4,237,509 System.Private.CoreLib.xml
                   3 File(s)      7,687,673 bytes
                   2 Dir(s)  1,438,163,804,160 bytes free
    
  4. ViktorHofer commented on Jul 29, 2020

    @ViktorHofer
    Member

    @jkotas @ericstj any idea what a "broken corelib" means? Figuring out how rebuilding (via a P2P) CoreLib could result in a different output. Maybe default properties which are set from the coreclr's root build aren't set?

  5. jkotas commented on Jul 29, 2020

    @jkotas
    Member

    Yes, the broken CoreLib is built with wrong defines. For example, TARGET_64BIT does not seem to be defined for it.

  6. danmoseley commented on Jul 29, 2020

    @danmoseley
    Contributor

    Does this repro in P8 branch?

  7. ViktorHofer commented on Jul 29, 2020

    @ViktorHofer
    Member

    Does this repro in P8 branch?

    Probably yes, but it's a developer innerloop issue only.

    Yes, the broken CoreLib is built with wrong defines. For example, TARGET_64BIT does not seem to be defined for it.

    OK I will diff that with a binarylog later. Thanks

  8. ViktorHofer commented on Jul 29, 2020

    @ViktorHofer
    Member

    Here's the diff when building from an sln which contains a project that P2Ps to CoreLib vs building CoreLib from the clr.corelib subset: https://www.diffchecker.com/mPYbuYIv.

    Just wanna share some findings, will take a closer look later.

  9. ghost locked as resolved and limited conversation to collaborators on Dec 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions