Skip to content

[mono] Portable threadpool does not support async IO eg ThreadPoolBoundHandle on Windows #34582

Closed

Description

@MaximLipnin

A lot of System.IO.Pipes.Tests fail with System.PlatformNotSupportedException : This API is specific to the way in which Windows handles asynchronous I/O, and is not supported on this platform. on windows.
The example of the output:

System.IO.Pipes.Tests.NamedPipeTest_Simple_ServerInOutRead_ClientInOutWrite.OperationsOnDisconnectedClient [FAIL]
System.PlatformNotSupportedException : This API is specific to the way in which Windows handles asynchronous I/O, and is not supported on this platform.
Stack Trace:
    _\src\libraries\System.Private.CoreLib\src\System\Threading\ThreadPoolBoundHandle.PlatformNotSupported.cs(25,0): at System.Threading.ThreadPoolBoundHandle.BindHandle(SafeHandle handle)
    _\src\libraries\System.IO.Pipes\src\System\IO\Pipes\PipeStream.Windows.cs(46,0): at System.IO.Pipes.PipeStream.InitializeAsyncHandle(SafePipeHandle handle)
    _\src\libraries\System.IO.Pipes\src\System\IO\Pipes\PipeStream.cs(101,0): at System.IO.Pipes.PipeStream.InitializeHandle(SafePipeHandle handle, Boolean isExposed, Boolean isAsync)
    _\src\libraries\System.IO.Pipes\src\System\IO\Pipes\NamedPipeServerStream.Windows.cs(122,0): at System.IO.Pipes.NamedPipeServerStream.Create(String pipeName, PipeDirection direction, Int32 maxNumberOfServerInstances, PipeTransmissionMode transmissionMode, PipeOptions options, Int32 inBufferSize, Int32 outBufferSize, PipeSecurity pipeSecurity, HandleInheritability inheritability, PipeAccessRights additionalAccessRights)
    _\src\libraries\System.IO.Pipes\src\System\IO\Pipes\NamedPipeServerStream.Windows.cs(49,0): at System.IO.Pipes.NamedPipeServerStream.Create(String pipeName, PipeDirection direction, Int32 maxNumberOfServerInstances, PipeTransmissionMode transmissionMode, PipeOptions options, Int32 inBufferSize, Int32 outBufferSize, HandleInheritability inheritability)
    _\src\libraries\System.IO.Pipes\src\System\IO\Pipes\NamedPipeServerStream.cs(85,0): at System.IO.Pipes.NamedPipeServerStream..ctor(String pipeName, PipeDirection direction, Int32 maxNumberOfServerInstances, PipeTransmissionMode transmissionMode, PipeOptions options, Int32 inBufferSize, Int32 outBufferSize, HandleInheritability inheritability)
    _\src\libraries\System.IO.Pipes\src\System\IO\Pipes\NamedPipeServerStream.cs(41,0): at System.IO.Pipes.NamedPipeServerStream..ctor(String pipeName, PipeDirection direction, Int32 maxNumberOfServerInstances, PipeTransmissionMode transmissionMode, PipeOptions options)
    _\src\libraries\System.IO.Pipes\tests\NamedPipeTests\NamedPipeTest.Simple.cs(761,0): at System.IO.Pipes.Tests.NamedPipeTest_Simple_ServerInOutRead_ClientInOutWrite.CreateNamedPipePair(PipeOptions serverOptions, PipeOptions clientOptions)
    _\src\libraries\System.IO.Pipes\tests\NamedPipeTests\NamedPipeTestBase.cs(42,0): at System.IO.Pipes.Tests.NamedPipeTestBase.CreateNamedPipePair()
    _\src\libraries\System.IO.Pipes\tests\NamedPipeTests\NamedPipeTest.Simple.cs(310,0): at System.IO.Pipes.Tests.NamedPipeTest_Simple.OperationsOnDisconnectedClient()

The whole namespace will be marked with ActiveIssue in #32592

Activity

  1. danmoseley commented on Apr 7, 2020

    @danmoseley
    Contributor

    @MaximLipnin this is because Mono corelib is not built with <FeaturePortableThreadPool>true</FeaturePortableThreadPool>. Should it be?
    cc @kouvel

  2. MaximLipnin commented on Apr 7, 2020

    @MaximLipnin
    ContributorAuthor

    @danmosemsft Thanks for clarification, but please correct me if I'm wrong - a quick search shows that this flag is activated in Mono's SPC

  3. kouvel commented on Apr 7, 2020

    @kouvel
    Contributor

    The portable thread pool implementation currently doesn't support BindHandle. I guess that Mono would inherit the PNSE implementation here:

    <ItemGroup Condition="'$(FeaturePortableThreadPool)' == 'true'">
    <Compile Include="$(MSBuildThisFileDirectory)System\AppContextConfigHelper.cs" />
    <Compile Include="$(MSBuildThisFileDirectory)System\Threading\ThreadPool.Portable.cs" />
    <Compile Include="$(MSBuildThisFileDirectory)System\Threading\ThreadPoolBoundHandle.PlatformNotSupported.cs" />

    I guess IO completion stuff may need to be added to the portable implementation on Windows to make BindHandle work there, I don't know if Mono has an alternative implementation it can fork to easily at the moment for those. Probably would be best to add that to the portable implementation.

  4. marek-safar commented on Apr 8, 2020

    @marek-safar
    Contributor

    <FeaturePortableThreadPool>true</FeaturePortableThreadPool>

    This is correct.

    Could the tests be guarded with IsBindHandleSupported instead of Windows only or is the BindHandle support something your team can fix?

    I know @jkotas would like to use portable TP for CoreCLR too and this could be a blocker.

  5. jkotas commented on Apr 8, 2020

    @jkotas
    Member

    @jkotas would like to use portable TP for CoreCLR too and this could be a blocker.

    Adding implementation for IO completion stuff (ie BindHandle and friends) is one of the things that will need to be fixed to fully switch to portable TP for CoreCLR on Windows.

    To understand the priority: Is Mono going to ship as officially supported on Windows for .NET 5?

  6. marek-safar commented on Apr 8, 2020

    @marek-safar
    Contributor

    It's not high on our priority list to support IO completion stuff anywhere (including Windows)

  7. danmoseley commented on Apr 9, 2020

    @danmoseley
    Contributor

    To understand the priority: Is Mono going to ship as officially supported on Windows for .NET 5?

    I am interested in this too as it helps us understand what to do about these mono-on-Windows bugs. My assumption is that there is value in getting this test pass clean, regardless.

    cc @steveisok

  8. changed the title [-][mono] Tests failed due to PNSE on windows: System.IO.Pipes.Tests[/-] [+][mono] Portable threadpool does not support async IO eg ThreadPoolBoundHandle[/+] on Apr 10, 2020
  9. added
    help wanted[up-for-grabs] Good issue for external contributors
    and removed
    untriagedNew issue has not been triaged by the area owner
    on Apr 10, 2020
  10. 6 remaining items

  11. changed the title [-][mono] Portable threadpool does not support async IO eg ThreadPoolBoundHandle[/-] [+][mono] Portable threadpool does not support async IO eg ThreadPoolBoundHandle on Windows[/+] on Jul 26, 2021
  12. SamMonoRT commented on Jul 26, 2021

    @SamMonoRT
    Member

    Moving to 7.0.0

  13. modified the milestones: 6.0.0, 7.0.0 on Jul 26, 2021
  14. lateralusX commented on Jan 13, 2022

    @lateralusX
    Member

    I guess IO completion stuff may need to be added to the portable implementation on Windows to make BindHandle work there, I don't know if Mono has an alternative implementation it can fork to easily at the moment for those. Probably would be best to add that to the portable implementation.

    @kouvel, any plans to actually implement support in portable thread pool so we can get this working on Mono?

  15. kouvel commented on Jan 20, 2022

    @kouvel
    Contributor

    any plans to actually implement support in portable thread pool so we can get this working on Mono?

    Yes I'm planning on adding support for BindHandle in the portable thread pool soon.

  16. ghost added
    in-prThere is an active PR which will close this issue when it is merged
    on Feb 7, 2022
  17. ghost removed
    in-prThere is an active PR which will close this issue when it is merged
    on Feb 7, 2022
  18. ghost added
    in-prThere is an active PR which will close this issue when it is merged
    on Feb 8, 2022
  19. ghost removed
    in-prThere is an active PR which will close this issue when it is merged
    on Mar 4, 2022
  20. ghost locked as resolved and limited conversation to collaborators on Apr 3, 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

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions