Skip to content

Microsoft.Extensions.Hosting.Tests.ConsoleLifetimeExitTests failing in Windows mono with PlatformNotSupportedException #57184

Closed

Description

@jozkee

EnsureEnvironmentExitDoesntHang and EnsureEnvironmentExitCode tests failing in CI:

Stack trace (similar call stack for EnsureEnvironmentExitDoesntHang):

at Microsoft.DotNet.RemoteExecutor.Program.Main(String[] args) in /_/src/Microsoft.DotNet.RemoteExecutor/src/Program.cs:line 94
    Microsoft.Extensions.Hosting.Tests.ConsoleLifetimeExitTests.EnsureEnvironmentExitCode [FAIL]
      Microsoft.DotNet.RemoteExecutor.RemoteExecutionException : Remote process failed with an unhandled exception.
      Stack Trace:
        
        Child exception:
          System.PlatformNotSupportedException: This API is specific to the way in which Windows handles asynchronous I/O, and is not supported on this platform.
        /_/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolBoundHandle.PlatformNotSupported.cs(24,0): at System.Threading.ThreadPoolBoundHandle.BindHandle(SafeHandle handle)
        /_/src/libraries/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.Win32.cs(76,0): at System.IO.FileSystemWatcher.StartRaisingEvents()
        /_/src/libraries/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.cs(638,0): at System.IO.FileSystemWatcher.StartRaisingEventsIfNotDisposed()
        /_/src/libraries/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.cs(151,0): at System.IO.FileSystemWatcher.set_EnableRaisingEvents(Boolean value)
        /_/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFilesWatcher.cs(416,0): at Microsoft.Extensions.FileProviders.Physical.PhysicalFilesWatcher.TryEnableFileSystemWatcher()
        /_/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFilesWatcher.cs(153,0): at Microsoft.Extensions.FileProviders.Physical.PhysicalFilesWatcher.CreateFileChangeToken(String filter)
        /_/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFileProvider.cs(359,0): at Microsoft.Extensions.FileProviders.PhysicalFileProvider.Watch(String filter)
        /_/src/libraries/Microsoft.Extensions.Configuration.FileExtensions/src/FileConfigurationProvider.cs(33,0): at Microsoft.Extensions.Configuration.FileConfigurationProvider.<.ctor>b__1_0()
        /_/src/libraries/Microsoft.Extensions.Primitives/src/ChangeToken.cs(71,0): at Microsoft.Extensions.Primitives.ChangeToken.ChangeTokenRegistration`1[[System.Action, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]..ctor(Func`1 changeTokenProducer, Action`1 changeTokenConsumer, Action state)
        /_/src/libraries/Microsoft.Extensions.Primitives/src/ChangeToken.cs(32,0): at Microsoft.Extensions.Primitives.ChangeToken.OnChange(Func`1 changeTokenProducer, Action changeTokenConsumer)
        /_/src/libraries/Microsoft.Extensions.Configuration.FileExtensions/src/FileConfigurationProvider.cs(32,0): at Microsoft.Extensions.Configuration.FileConfigurationProvider..ctor(FileConfigurationSource source)
        /_/src/libraries/Microsoft.Extensions.Configuration.Json/src/JsonConfigurationProvider.cs(20,0): at Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider..ctor(JsonConfigurationSource source)
        /_/src/libraries/Microsoft.Extensions.Configuration.Json/src/JsonConfigurationSource.cs(21,0): at Microsoft.Extensions.Configuration.Json.JsonConfigurationSource.Build(IConfigurationBuilder builder)
        /_/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationBuilder.cs(51,0): at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()
        /_/src/libraries/Microsoft.Extensions.Hosting/src/HostBuilder.cs(230,0): at Microsoft.Extensions.Hosting.HostBuilder.BuildAppConfiguration()
        /_/src/libraries/Microsoft.Extensions.Hosting/src/HostBuilder.cs(146,0): at Microsoft.Extensions.Hosting.HostBuilder.Build()
        /_/src/libraries/Microsoft.Extensions.Hosting/src/HostingHostBuilderExtensions.cs(329,0): at Microsoft.Extensions.Hosting.HostingHostBuilderExtensions.RunConsoleAsync(IHostBuilder hostBuilder, CancellationToken cancellationToken)
        /_/src/libraries/Microsoft.Extensions.Hosting/tests/UnitTests/ConsoleLifetimeExitTests.cs(101,0): at Microsoft.Extensions.Hosting.Tests.ConsoleLifetimeExitTests.<>c.<<EnsureEnvironmentExitCode>b__6_0>d.MoveNext()
        --- End of stack trace from previous location ---
        /_/src/Microsoft.DotNet.RemoteExecutor/src/Program.cs(65,0): at Microsoft.DotNet.RemoteExecutor.Program.Main(String[] args)
        
        Child process:
          Microsoft.Extensions.Hosting.Unit.Tests, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60 Microsoft.Extensions.Hosting.Tests.ConsoleLifetimeExitTests+<>c System.Threading.Tasks.Task <EnsureEnvironmentExitCode>b__6_0()

helix log:
https://helixre8s23ayyeko0k025g8.blob.core.windows.net/dotnet-runtime-refs-pull-57136-merge-bab87ae1deee44e781/Microsoft.Extensions.Hosting.Unit.Tests/1/console.5019bb6b.log?sv=2019-07-07&se=2021-08-30T17%3A49%3A01Z&sr=c&sp=rl&sig=7qWWC35E1bcjEZiPSz9pB%2FQgg9TclDqq4GitesFZtpI%3D

Activity

  1. ghost added
    untriagedNew issue has not been triaged by the area owner
    on Aug 11, 2021
  2. eerhardt commented on Aug 11, 2021

    @eerhardt
    Member

    Why isn’t this always failing if it is a PNSE?

    I see the error is coming from the FileSystemWatcher. Is there something about the watcher that is non-deterministic?

  3. davidfowl commented on Aug 11, 2021

    @davidfowl
    Member

    Do we run mono tests on windows or are the wrong assets getting copied

  4. eerhardt commented on Aug 11, 2021

    @eerhardt
    Member

    We run mono tests on windows. There are numerous hosting tests already disabled for this issue:

    [Fact]
    [ActiveIssue("https://github.com/dotnet/runtime/issues/34582", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)]
    public void CreateDefaultBuilder_IncludesContentRootByDefault()

    [Fact]
    [ActiveIssue("https://github.com/dotnet/runtime/issues/34582", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)]
    public void CreateDefaultBuilder_IncludesCommandLineArguments()

    But I would have thought if a test was going to fail for this error, it would always fail. I can easily add the ActiveIssue attributes like above to these tests. But I'd like to understand why the error doesn't always happen.

    cc @steveisok @SamMonoRT

  5. steveisok commented on Aug 11, 2021

    @steveisok
    Member

    @eerhardt I saw these today and marked them for skipping in #57114

    As for why it's flaky, I'm not sure and that is weird. @lateralusX would probably know best when he comes back from vacation.

  6. removed
    untriagedNew issue has not been triaged by the area owner
    on Aug 11, 2021
  7. added this to the 6.0.0 milestone on Aug 11, 2021
  8. danmoseley commented on Aug 11, 2021

    @danmoseley
    Contributor

    Hit again in #57235

  9. ghost added
    in-prThere is an active PR which will close this issue when it is merged
    on Aug 12, 2021
  10. ghost removed
    in-prThere is an active PR which will close this issue when it is merged
    on Aug 13, 2021
  11. added a commit that references this issue on Aug 13, 2021
    defa26b
  12. lateralusX commented on Aug 24, 2021

    @lateralusX
    Member

    @steveisok, just doing a quick look at the code it looks like it should be deterministic, given that the things being watched are always present on file system. Should we spend time to investigate this (Mono on Windows is not an official supported platform) or do a bigger pass once/if we decide to move ahead with Mono Windows support and decide to use an implementation of ThreadPoolBoundHandle not raising PNSE?

  13. ghost locked as resolved and limited conversation to collaborators on Sep 23, 2021
  14. added a commit that references this issue on Dec 5, 2022
    c3d50b0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions