Skip to content

eio_windows: fix anonymous pipes on Windows - #929

Open
avsm wants to merge 2 commits into
ocaml-multicore:mainfrom
avsm:failing-win-pipe
Open

eio_windows: fix anonymous pipes on Windows#929
avsm wants to merge 2 commits into
ocaml-multicore:mainfrom
avsm:failing-win-pipe

Conversation

@avsm

@avsm avsm commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

This is a testcase failing on my machine atm, so opening to check windows CI here as well (I'm struggling with Windows Redirection Guard nuking my ssh setup due to the use of symlinks in Flexlink!)

@avsm

avsm commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Confirming it fails in CI too

 [FAIL]        pipe             0   transfer.
  
    ... with 6 subsequent tests skipped.
  
  ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ [FAIL]        pipe             0   transfer.                                                                         │
  └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
  [exception] Eio.Io _
              Raised at Stdlib__Effect.Deep.discontinue.(fun) in file "effect.ml", line 63, characters 41-48
              Called from Eio_unix__Private.pipe in file "lib_eio/unix/private.ml", line 14, characters 13-37
              Called from Dune__exe__Test_pipe.test_transfer.(fun) in file "lib_eio_windows/test/test_pipe.ml", line 12, characters 13-29
              Called from Eio__core__Switch.run_internal in file "lib_eio/core/switch.ml", line 133, characters 8-12
              Re-raised at Eio__core__Switch.maybe_raise_exs in file "lib_eio/core/switch.ml", line 119, characters 21-56
              Called from Eio__core__Switch.run_internal in file "lib_eio/core/switch.ml", line 149, characters 4-21
              Called from Eio__core__Cancel.with_cc in file "lib_eio/core/cancel.ml", line 118, characters 8-12
              Re-raised at Eio__core__Cancel.with_cc in file "lib_eio/core/cancel.ml", line 120, characters 50-58
              Called from Alcotest_engine__Core.Make.protect_test.(fun) in file "src/alcotest-engine/core.ml", line 186, characters 17-23
              Called from Alcotest_engine__Monad.Identity.catch in file "src/alcotest-engine/monad.ml", line 24, characters 31-35

@avsm
avsm marked this pull request as ready for review September 1, 2026 19:04
@talex5 talex5 added the windows label Sep 2, 2026
@avsm avsm changed the title eio_windows: test case for anonymous pipes eio_windows: fix anonymous pipes on Windows Sep 2, 2026
@avsm

avsm commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

I'm going to layer the process spawnign PR over this one; I can't do a full test case for a failing pipe without another process!

On Windows,an anonymous pipe cant be made non-blocking, so
this call always failed with an ENOTSOCK for me.
We now use a pool thread for blocking reads and writes.

@talex5 talex5 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look right - how will cancellation work?

According to https://stackoverflow.com/questions/34504970/non-blocking-read-on-os-pipe-on-windows, Windows does support non-blocking reads on pipes:

SetNamedPipeHandleState doc allows to put anonymous pipe to non-blocking mode.

Also, we probably want the same check for blocking mode that's in eio_posix. There, we have e.g.

let read fd buf start len =
if Fd.is_blocking fd then await_readable "read" fd;
Fd.use_exn "read" fd @@ fun fd ->
do_nonblocking Read "read" (fun fd -> Unix.read fd buf start len) fd

But in eio_windows, the wait is unconditional:

let read fd buf start len =
await_readable fd;
Fd.use_exn "read" fd @@ fun fd ->
do_nonblocking Read (fun fd -> Unix.read fd buf start len) fd


open Eio.Std

let read_all flow =

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do have Eio.Flow.read_all.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need this expanded to put debug printfs in! Not actually tried cancellations in, will do next: I think I've found one potential weirdness which is that the pipe behaviour changes if I SSH in vs run at the machine directly! Windows is driving me mad, mad I tell you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants