Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007342OCamlplatform support (windows, cross-compilation, etc)public2016-08-31 17:592016-12-16 03:49
Reporterprotz 
Assigned Toprotz 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version4.05.0 +dev/beta1/beta2/beta3/rc1 
Target Version4.05.0 +dev/beta1/beta2/beta3/rc1Fixed in Version4.05.0 +dev/beta1/beta2/beta3/rc1 
Summary0007342: Unix.read exhibits two different behaviors on Windows vs Linux
DescriptionReading Didier and Xavier's excellent "Unix programming in OCaml" course, I performed a `Unix.read` on a descriptor, expecting to read 0 when the descriptor had nothing left in it.

Sadly, I was developing on Windows. It turns out that `Unix.read` throws `EPIPE` there instead (see https://github.com/ocsigen/lwt/issues/20 [^] for another project that performed a workaround there).
Steps To ReproduceSee the attached file.

# #use "Test.ml";;
- : unit = ()

# run "ls" [||];;
Exception: Unix.Unix_error (Unix.EPIPE, "read", "").

The workaround is to remove the "when false" clause in Test.ml.
Additional InformationI can submit a pull request that wraps otherlibs/win32unix/unix.ml:read with that exact try-catch block, or I can submit a documentation request that documents this caveat. Any preference?
TagsNo tags attached.
Attached Files? file icon Test.ml [^] (807 bytes) 2016-08-31 17:59 [Show Content]

- Relationships

-  Notes
(0016254)
gasche (developer)
2016-08-31 18:24

As a mostly-unix programmer I would have a preference for the documented behavior (also in `man 3 read` on the C side) to work reliably on Windows -- I'm sure I would have been confused by the issue if people tried my software on Windows.
(0016255)
xleroy (administrator)
2016-08-31 19:03

Another Win32/Unix gratuitous difference, wonderful.

My preferred fix would be to change win32unix/read.c so that a GetLastError() code ERROR_BROKEN_PIPE is turned into a return of 0.
(0016271)
protz (manager)
2016-09-07 20:27

https://github.com/ocaml/ocaml/pull/797 [^]
(0017014)
gasche (developer)
2016-12-16 03:49

Fixed by merging GPR#797.

- Issue History
Date Modified Username Field Change
2016-08-31 17:59 protz New Issue
2016-08-31 17:59 protz File Added: Test.ml
2016-08-31 18:24 gasche Note Added: 0016254
2016-08-31 19:03 xleroy Note Added: 0016255
2016-09-07 16:47 shinwell Target Version => 4.05.0 +dev/beta1/beta2/beta3/rc1
2016-09-07 20:27 protz Note Added: 0016271
2016-11-08 11:56 doligez Status new => acknowledged
2016-12-16 03:49 gasche Note Added: 0017014
2016-12-16 03:49 gasche Status acknowledged => resolved
2016-12-16 03:49 gasche Fixed in Version => 4.05.0 +dev/beta1/beta2/beta3/rc1
2016-12-16 03:49 gasche Resolution open => fixed
2016-12-16 03:49 gasche Assigned To => protz
2017-02-23 16:46 doligez Category OCaml windows => platform support (windows, etc)
2017-02-23 17:16 doligez Category platform support (windows, etc) => platform support (windows, cross-compilation, etc)


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker