Skip to content

Test Failed: GetGCMemoryInfo returns negative value on ARM32 #13115

Closed

Description

@VincentBu

Job:
https://mc.dot.net/#/user/coreclr-corefx/ci~2Fdotnet~2Fcoreclr~2Frefs~2Fheads~2Fmaster/test~2Ffunctional~2Fcorefx~2F/20190721.1/workItem/System.Runtime.Tests/analysis/xunit/System.Tests.GCTests~2FGetGCMemoryInfo

Log:

Child exception:
  Xunit.Sdk.InRangeException: Assert.InRange() Failure
Range:  (1 - 9223372036854775807)
Actual: -1844674407689672704
   at System.Tests.GCTests.<>c.<GetGCMemoryInfo>b__29_0() in /_/src/System.Runtime/tests/System/GCTests.netcoreapp.cs:line 35

Child process:
  System.Runtime.Tests, Version=4.2.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 System.Tests.GCTests+<>c Void <GetGCMemoryInfo>b__29_0()

Activity

  1. danmoseley commented on Jul 22, 2019

    @danmoseley
    Contributor
  2. Maoni0 commented on Jul 22, 2019

    @Maoni0
    Member

    @VSadov would you please take a look?

  3. VSadov commented on Jul 22, 2019

    @VSadov
    Member

    #12639 was a test issue and should be fixed.

    This looks like a new failure. Here the API seems to return a bogus result.

  4. self-assigned this
    on Jul 22, 2019
  5. VSadov commented on Jul 22, 2019

    @VSadov
    Member

    We did not have any changes around this API, except dotnet/coreclr#25724

    @cshung can you take a quick look if the change could cause this?
    It looks like we get negative memory size on ARM32

  6. changed the title [-]Microsoft.DotNet.RemoteExecutor.RemoteExecutionException : Remote process failed with an unhandled exception.[/-] [+]GetGCMemoryInfo returns negative value on ARM32[/+] on Jul 23, 2019
  7. changed the title [-]GetGCMemoryInfo returns negative value on ARM32[/-] [+]Test Failed: GetGCMemoryInfo returns negative value on ARM32[/+] on Aug 22, 2019
  8. sergiy-k commented on Aug 23, 2019

    @sergiy-k
    Contributor

    @cshung, did you have a chance to look at this failure and check whether it is related to your change?

  9. cshung commented on Aug 23, 2019

    @cshung
    Contributor

    I didn't. I was told this is a low priority bug, after all, it only repros on Linux ARM32.

    Earlier I fixed a compiler warning related to integer overflow and discovered that the CGroup could return bogus value as PhysicalMemoryLimit and RestrictedPhysicalMemoryLimit. IMHO, that looks like a kernel/docker bug. In particular, the values read from the files are larger than size_t::max(), which is simply impossible.

    The original code ignored the compiler warning, so the value probably got wrapped and passed the test. My new value clipped it to size_t::max(), which is probably the best I could have done the preserve the meaning [basically I am saying the PhysicalMemoryLimit and RestrictedPhysicalMemoryLimit is as much as the system could have].

    I doubt somewhere the number got marshaled to managed code as a signed integer. If we know where that spot is, we can try to do the same clipping there. Of course, the bug could be completely unrelated, this is just my suspicion.

    Is it a priority to fix this?

  10. sergiy-k commented on Aug 23, 2019

    @sergiy-k
    Contributor

    I would like to understand whether we have to fix this issue in 3.1

  11. cshung commented on Aug 23, 2019

    @cshung
    Contributor

    Does the bug repro in 3.0? I thought the change was introduced after it.

  12. sergiy-k commented on Aug 23, 2019

    @sergiy-k
    Contributor

    Oh, never mind. I'm sorry for the confusion. For some reason I thought that the change was merged in June instead of July. So it is not high priority but I would like have it fixed relatively soon (in a few weeks) in order to avoid accumulating test bugs.

  13. cshung commented on Aug 26, 2019

    @cshung
    Contributor

    Today I attempted to repro this bug, and I am unable to, here is my exact setup.

    These commands are all ran on a Ubuntu 16.04 LTS physical machine.

    I build CoreCLR for Linux ARM from source:

    This is the commit I was on:

    4519204c19833104451003886b23c39218a48a23

    This is the command I used to build CoreCLR:

    docker run --rm -v /home/andrewau/git/coreclr:/coreclr -w /coreclr -e ROOTFS_DIR=/crossrootfs/arm mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-16.04-cross-14.04-23cacb0-20190528233931 ./build.sh arm cross

    After the CoreCLR is built, I need to prepare the managed code to repro, to do that, I installed dotnet core preview 8, here is my dotnet --info output:

    .NET Core SDK (reflecting any global.json):
     Version:   3.0.100-preview8-013656
     Commit:    8bf06ffc8d
    
    Runtime Environment:
     OS Name:     ubuntu
     OS Version:  16.04
     OS Platform: Linux
     RID:         ubuntu.16.04-x64
     Base Path:   /home/andrewau/dotnet/sdk/3.0.100-preview8-013656/
    
    Host (useful for support):
      Version: 3.0.0-preview8-28405-07
      Commit:  d01b2fb7bc
    
    .NET Core SDKs installed:
      3.0.100-preview8-013656 [/home/andrewau/dotnet/sdk]
    
    .NET Core runtimes installed:
      Microsoft.AspNetCore.App 3.0.0-preview8.19405.7 [/home/andrewau/dotnet/shared/Microsoft.AspNetCore.App]
      Microsoft.NETCore.App 3.0.0-preview8-28405-07 [/home/andrewau/dotnet/shared/Microsoft.NETCore.App]
    
    To install additional .NET Core runtimes or SDKs:
      https://aka.ms/dotnet-download
    

    Using dotnet new console, I created a blank console application, replaced the source code with the following:

    using System;
    
    namespace repro
    {
        class Program
        {
            static void Main(string[] args)
            {
                GCMemoryInfo memoryInfo1 = GC.GetGCMemoryInfo();
    
                Console.WriteLine(memoryInfo1.HighMemoryLoadThresholdBytes);
                Console.WriteLine(memoryInfo1.MemoryLoadBytes);
                Console.WriteLine(memoryInfo1.TotalAvailableMemoryBytes);
                Console.WriteLine(memoryInfo1.HeapSizeBytes);
                Console.WriteLine(memoryInfo1.FragmentedBytes);
            }
        }
    }
    

    Then I published the app using linux-arm as my runtime identifier.

    dotnet publish -r linux-arm --self-contained

    With that, I replaced all the coreclr binaries with my local build:

    cp -R ~/git/coreclr/bin/Product/Linux.arm.Debug ~/repro/bin/Debug/netcoreapp3.0/linux-arm/publish

    Finally, I copied the bits to a Raspberry PI using rsync

    rsync -auz --info=progress2 ~/repro/bin/Debug/netcoreapp3.0/linux-arm/publish [hidden]@[hidden]:~/repro

    Running the copied repro on the PI, here is what I get:

    873960652
    0
    971067392
    0
    0
    

    None of the numbers are negative.

    I suspect there must be something special setup on the Linux arm devices used for the run, it might be running some sort of docker that mess it up.

    Update:
    Thanks to @hoyosjs, I was able to get docker running on the Raspberry PI, with that, I was able to run the scenario on the same docker image as it is on the CI. I still get exactly the same numbers. Also tried to run the scenario in a hot loop, it never outputs any negative numbers.

  14. ViktorHofer commented on Aug 29, 2019

    @ViktorHofer
    Member

    With how many iterations did you test? If less than 1k I would try it again with that number. Some flaky tests are hard to reproduce.

  15. hoyosjs commented on Aug 29, 2019

    @hoyosjs
    Member

    I did 10k, no negative numbers. Don't know what the lab setup is to see if it's related.

  16. sergiy-k commented on Aug 29, 2019

    @sergiy-k
    Contributor

    Is it possible to get a crash dump from the lab?

  17. ViktorHofer commented on Aug 29, 2019

    @ViktorHofer
    Member

    There were no crashes, the negative number was just reported as an xunit assertexception.

  18. sergiy-k commented on Aug 29, 2019

    @sergiy-k
    Contributor

    It will be very hard to get to the bottom of this issue without a crash dump given that the problem does not reproduce on local machines. We need to make the test generate a dump file when it fails. How do we do it?
    It would be very cool if Xunit could be configured to generate a crush dump if an assert fails (maybe based on an attribute that we can set on demand).

  19. ViktorHofer commented on Aug 30, 2019

    @ViktorHofer
    Member

    It would be very cool if Xunit could be configured to generate a crush dump if an assert fails (maybe based on an attribute that we can set on demand).

    @bradwilson @onovotny is that somehow possible?

  20. stephentoub commented on Aug 30, 2019

    @stephentoub
    Member

    You could Environment.FailFast instead of Assert.Whatever.

  21. transferred this issue fromdotnet/coreclron Jan 31, 2020
  22. added this to the 5.0 milestone on Jan 31, 2020
  23. assigned and unassigned on Feb 13, 2020
  24. mangod9 commented on Jul 24, 2020

    @mangod9
    Member

    @cshung do we know if this is still an issue which needs to be investigated?

  25. cshung commented on Jul 27, 2020

    @cshung
    Contributor

    @cshung do we know if this is still an issue which needs to be investigated?

    @mangod9

    I have double checked our test exclusion list. It appears to me that the test is no longer excluded.

    This issue concerns the GCTests, and it is not mentioned in the exclusion list. Searching GCTests in that file results in no match.

    Searching through the file, there is a match for GCMemoryInfo.

    <ExcludeList Include="$(XunitTestBinBase)/GC/API/GC/GetGCMemoryInfo/**">

    However, it is not the GCTests that is being referred to in this issue. Upon careful inspection, this applies to mono only, so I think we are good to close this issue if the test is indeed running and no failure reported.

    @ViktorHofer, who initially disabled the test, to confirm that the test is not currently being disabled.

  26. mangod9 commented on Aug 14, 2020

    @mangod9
    Member

    Closing based on the comment above

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

Metadata

Metadata

Assignees

Labels

arch-arm32area-GC-coreclros-linux

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions