Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
alnikola opened this issue Jul 29, 2020 · 8 comments · Fixed by #40097
Closed

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

alnikola opened this issue Jul 29, 2020 · 8 comments · Fixed by #40097
Labels
area-Infrastructure-libraries untriaged New issue has not been triaged by the area owner
Milestone

Comments

@alnikola
Copy link
Contributor

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)
@alnikola alnikola added this to the 5.0.0 milestone Jul 29, 2020
@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added the untriaged New issue has not been triaged by the area owner label Jul 29, 2020
@john-h-k
Copy link
Contributor

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

@jkotas
Copy link
Member

jkotas commented Jul 29, 2020

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

@ghost
Copy link

ghost commented Jul 29, 2020

Tagging subscribers to this area: @safern, @ViktorHofer
See info in area-owners.md if you want to be subscribed.

@ViktorHofer
Copy link
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?

@jkotas
Copy link
Member

jkotas commented Jul 29, 2020

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

@danmoseley
Copy link
Member

Does this repro in P8 branch?

@ViktorHofer
Copy link
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

@ViktorHofer
Copy link
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.

@ghost ghost locked as resolved and limited conversation to collaborators Dec 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Infrastructure-libraries untriaged New issue has not been triaged by the area owner
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants