Skip to content

[Mono] Test failed on windows: System.Collections.Concurrent.Tests.BlockingCollectionTests.Test_LargeSize_STA #34360

Open

Description

@MaximLipnin

System.Collections.Concurrent.Tests.BlockingCollectionTests.Test_LargeSize_STA is disabled in Mono's CoreFX.issues_windows.rsp file. After enabling it still fails locally with the following output:

System.Collections.Concurrent.Tests.BlockingCollectionTests.Test_LargeSize_STA [FAIL]
System.InvalidOperationException : Failed to set the specified COM apartment state.
Stack Trace:
    _\src\libraries\System.Private.CoreLib\src\System\Threading\Thread.cs(234,0): at System.Threading.Thread.SetApartmentState(ApartmentState state)
    _\src\libraries\System.Collections.Concurrent\tests\BlockingCollectionTests.cs(985,0): at System.Collections.Concurrent.Tests.BlockingCollectionTests.Test_LargeSize_STA()
    _\src\mono\netcore\System.Private.CoreLib\src\System\Reflection\RuntimeMethodInfo.cs(360,0): at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

The test will be marked with ActiveIssue in #32592.

Activity

  1. added
    untriaged
    on Apr 1, 2020
  2. added
    runtime-mono
    on Apr 1, 2020
  3. marek-safar commented on Apr 8, 2020

    @marek-safar
    Contributor

    @danmosemsft issues like this one are not Mono specific. They have wrong conditional facts, it should be IsCOMSupported or something similar instead of nameof(PlatformDetection.IsNotWindowsNanoServer)

    Can your team help with cleaning up the wrong facts?

  4. removed
    runtime-mono
    on Apr 8, 2020
  5. danmoseley commented on Apr 8, 2020

    @danmoseley
    Contributor

    Would it make sense for @MaximLipnin to make that small change?

    In general I don’t think it makes sense to do much of this cleanup “blind” where we can’t see the result of what we did.

  6. marek-safar commented on Apr 8, 2020

    @marek-safar
    Contributor

    In general I don’t think it makes sense to do much of this cleanup “blind” where we can’t see the result of what we did.

    There is about 140 tests disabled with PlatformDetection.IsNotWindowsNanoServer. I very much doubt many if all of them are really Nano Server specific and not disabled .NET features. Using the correct condition would help us to see which tests are real failures on new .NET5 platforms so this is not going blind but categorize libraries tests exclusion correctly.

  7. danmoseley commented on Apr 8, 2020

    @danmoseley
    Contributor

    Yes, I agree it would be better for many of those to be replaced with capability tests eg., like this pattern

    protected static bool IsElevatedAndSupportsEventLogs => IsProcessElevated && PlatformDetection.IsNotWindowsNanoServer;
    ...
            [ConditionalFact(nameof(IsElevatedAndSupportsEventLogs))]
            public void LogWritten()

    We can and should do that where possible

    That said what is the issue in this case? The test is annotated because Windows Nano Server does not support creating STA threads. Is that not supported on Mono period? I do see it rejected in the mono corelib

    private bool TrySetApartmentStateUnchecked(ApartmentState state) => state == ApartmentState.Unknown;

    but I also see code in the Mono runtime for STA thread. Is there a Mono limitation that it cannot change apartment state? If so should we decide whether that should be fixed? That would tell us whether we need a test like PlatformDetection.SupportsChangingApartmentState or it's just a bug.

  8. danmoseley commented on Apr 8, 2020

    @danmoseley
    Contributor

    I also see that Thread.Mono.cs will never report anything other than ApartmentState.Unknown.

  9. marek-safar commented on Apr 9, 2020

    @marek-safar
    Contributor

    In general, MonoVM does not support COM on any platform. Whether it's better to exclude this test with feature described as COM or smaller one is one of the reasons why I think your team would be better to handle this as they have a broader view on all possible combinations.

  10. danmoseley commented on Apr 10, 2020

    @danmoseley
    Contributor

    OK. Then we should add in PlatformDetection.cs

            // Mono does not support COM Interop, even setting thread apartment state
            public static bool IsComSupported => IsWindows && !IsMonoRuntime;
            public static bool IsNotComSupported => !IsComInteropSupported;
    

    and conditionalize tests here and those listed in
    #34442
    #34685
    #34689

    I didn't distinguish COM interop from setting thread apartment since they generally go together/

  11. added
    runtime-mono
    on Apr 10, 2020
  12. added this to the 6.0.0 milestone on Jun 24, 2020
  13. removed
    untriaged
    on Jun 24, 2020
  14. eiriktsarpalis commented on Aug 12, 2021

    @eiriktsarpalis
    Member

    Moving to 7.0.0

  15. modified the milestones: 6.0.0, 7.0.0 on Aug 12, 2021
  16. modified the milestones: 7.0.0, Future on Jul 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions