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

Test: System.Tests.StringTests/Ctor_CharSpan failed with "System.NullReferenceException" & "System.OutOfMemoryException" #23036

Closed
ghost opened this issue Aug 3, 2017 · 9 comments

Comments

@ghost
Copy link

ghost commented Aug 3, 2017

Opened on behalf of @JiayiLi1

The test System.Tests.StringTests/Ctor_CharSpan(valueArray: ['a', 'b', 'c', 'd', 'e', ...], startIndex: 0, length: 12, expected: \"abcdefgh\\0ijk\") has failed.

System.NullReferenceException : Object reference not set to an instance of an object.

    Stack Trace:

       at System.String.Ctor() in f:\dd\ndp\fxcore\CoreRT\src\System.Private.CoreLib\src\System\String.cs:line 15732480
   at System.Tests.StringTests.Ctor_CharSpan() in E:\A\_work\305\s\corefx\src\System.Runtime\tests\System\StringTests.netcoreapp.cs:line 32
   at _$ILCT$.$ILT$ReflectionDynamicInvoke$.InvokeRetVIIII<System.__Canon, System.Int32, System.Int32, System.__Canon>()
   at System.InvokeUtils.CalliIntrinsics.Call()
   at System.InvokeUtils.CallDynamicInvokeMethod() in CallDynamicInvokeMethod:line 16707566

Build : Master - 20170803.01 (UWP ILC Tests)
Failing configurations:

  • Windows.10.Amd64.ClientRS3-x64
    • Release
    • Debug
  • Windows.10.Amd64.ClientRS3-x86
    • Debug
    • Release

Detail: https://mc.dot.net/#/product/netcore/master/source/official~2Fcorefx~2Fmaster~2F/type/test~2Ffunctional~2Filc~2F/build/20170803.01/workItem/System.Runtime.Tests/analysis/xunit/System.Tests.StringTests~2FCtor_CharSpan(valueArray:%20%5B'a',%20'b',%20'c',%20'd',%20'e',%20...%5D,%20startIndex:%200,%20length:%2012,%20expected:%20%5C%22abcdefgh%5C%5C0ijk%5C%22)

@joperezr
Copy link
Member

joperezr commented Aug 3, 2017

This looks like it's a new test that was added recently on PR dotnet/corefx#22673. @stephentoub is this supposed to work on uapaot?

@stephentoub
Copy link
Member

is this supposed to work on uapaot?

The ctor was added in dotnet/corert#4233, but if we don't have a uapaot leg in CI, it's possible it's not functioning correctly.

What does it mean that it failed on line 15732480?

cc: @jkotas

@joperezr
Copy link
Member

joperezr commented Aug 3, 2017

I've never really trusted the line numbers since everything gets compiled and optimized into one executable so line numbers might be off. I can put this under the debugger and tell you exactly which line is failing.

@MichalStrehovsky
Copy link
Member

Line number 15732480 is 0xF00F00. 0xFEEFEE and 0xF00F00 are special.

Cc @trylek @cshung if there's something that can be done about it.

@joperezr
Copy link
Member

joperezr commented Aug 3, 2017

@MichalStrehovsky There are two tests that are failing, and I suspect that at least one of them is codegen bug. Test Ctor_CharSpan passes fine when ILCBuildType is set to chk so do you mind taking a look?

Ctor_CharSpan_EmptyString test does seem to be an issue, which is throwing out of memory exception. I'll get the line numer details and a better callstack and hand it to @stephentoub

@trylek
Copy link
Member

trylek commented Aug 3, 2017

@joperezr I have found the cause of the Ctor_CharSpan bug - there's a bug in Corelib, the String.Ctor method was not marked as "static". This basically caused a calling convention mismatch on amd64 as we were passing the ReadOnlySpan in rcx but the method expected it in rdx. It looks like unoptimized build happened to populate both registers with the proper reference to the span. Even though the Ctor_CharSpan_EmptyString is locally passing for me, I suspect that an OOM could be easily explained by this too (assuming you're talking about a runtime, not a compile-time OOM). I have already received sign-off on the fix from Michal, I'm about to check it in after finishing pre-checkin testing i.e. the fix should be included in tonight .NET Native drop.

@stephentoub
Copy link
Member

the String.Ctor method was not marked as "static"

Oops! Thank you for investigating and fixing.

@trylek
Copy link
Member

trylek commented Aug 3, 2017

It has been my pleasure Steve :-). The fix is in ProjectN as of CS #1669109. This is just for reference once the tests start failing again.

@danmoseley
Copy link
Member

fixed

Dotnet-GitSync-Bot referenced this issue in Dotnet-GitSync-Bot/corefx Apr 3, 2019
The OnProcessExit was iterating over the s_contextsToUnload and calling
Unload on each of the contexts. However the s_contextsToUnload is a
misnomer, it contains all the contexts, both collectible and
non-collectible ones. So we were calling Unload on non-collectible
contexts too there. That resulted in InvalidOperationException being
thrown from the OnProcessExit.

This change fixes that by calling unload only on ALCs whose
IsCollectible returns true. It also renames the s_contextsToUnload to
s_allContexts.

Close #22902

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
stephentoub referenced this issue in dotnet/corefx Apr 3, 2019
The OnProcessExit was iterating over the s_contextsToUnload and calling
Unload on each of the contexts. However the s_contextsToUnload is a
misnomer, it contains all the contexts, both collectible and
non-collectible ones. So we were calling Unload on non-collectible
contexts too there. That resulted in InvalidOperationException being
thrown from the OnProcessExit.

This change fixes that by calling unload only on ALCs whose
IsCollectible returns true. It also renames the s_contextsToUnload to
s_allContexts.

Close #22902

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the UWP6.1 milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants