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

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

Closed
jozkee opened this issue Aug 11, 2021 · 7 comments · Fixed by #57114
Assignees
Labels
area-Extensions-Hosting runtime-mono specific to the Mono runtime
Milestone

Comments

@jozkee
Copy link
Member

jozkee commented Aug 11, 2021

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

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Aug 11, 2021
@ghost
Copy link

ghost commented Aug 11, 2021

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

Issue Details

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

Author: Jozkee
Assignees: -
Labels:

area-Extensions-Hosting

Milestone: -

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

@davidfowl
Copy link
Member

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

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

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

@eerhardt eerhardt removed the untriaged New issue has not been triaged by the area owner label Aug 11, 2021
@eerhardt eerhardt added this to the 6.0.0 milestone Aug 11, 2021
@danmoseley
Copy link
Member

Hit again in #57235

@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Aug 12, 2021
@maryamariyan maryamariyan added the runtime-mono specific to the Mono runtime label Aug 12, 2021
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Aug 13, 2021
steveisok added a commit that referenced this issue Aug 13, 2021
…ew other tests (#57114)

Since the library is PNSE by default, make sure the tests do not run on mobile.
Also skips a few other tests.

Closes #57184
@lateralusX
Copy link
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?

@ghost ghost locked as resolved and limited conversation to collaborators Sep 23, 2021
ViktorHofer pushed a commit to dotnet/winforms that referenced this issue Dec 5, 2022
…ew other tests (dotnet/runtime#57114)

Since the library is PNSE by default, make sure the tests do not run on mobile.
Also skips a few other tests.

Closes dotnet/runtime#57184

Commit migrated from dotnet/runtime@defa26b
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Extensions-Hosting runtime-mono specific to the Mono runtime
Projects
None yet
7 participants