-
Notifications
You must be signed in to change notification settings - Fork 409
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
Dune upgrades to 3.9.2 but fails to build other packages (Mint, ecryptfs) #8284
Comments
When I cloned Dune and ran
which resemble the errors I got when Dune 3.9.2 was building the other packages. |
I did a little print_endline debugging. When I make the following change to diff --git a/otherlibs/stdune/src/io.ml b/otherlibs/stdune/src/io.ml
index 48cbc3e09..68b482e5e 100644
--- a/otherlibs/stdune/src/io.ml
+++ b/otherlibs/stdune/src/io.ml
@@ -136,16 +136,20 @@ module Copyfile = struct
Eventually, we should stop using exceptions for signalling these
errors. But that's a bit of a large change since there's a lot of
exception catching to audit. *)
+ print_endline "Entering";
match setup_copy ?chmod ~src ~dst () with
- | Error (`Exn exn) -> Exn_with_backtrace.reraise exn
- | Error `Src_is_a_dir -> raise (Sys_error "Is a directory")
+ | Error (`Exn exn) -> print_endline "A"; Exn_with_backtrace.reraise exn
+ | Error `Src_is_a_dir -> print_endline "B"; raise (Sys_error "Is a directory")
| Error `Dst_is_a_dir ->
+ print_endline "C";
let message = Printf.sprintf "%s: Is a directory" dst in
raise (Sys_error message)
| Error `Src_missing ->
+ print_endline "D";
let message = Printf.sprintf "%s: No such file or directory" src in
raise (Sys_error message)
| Ok (src, dst, src_size) ->
+ print_endline "E";
Exn.protect
~f:(fun () ->
try sendfile ~src ~dst src_size and then run
So, the code reaches the path I labeled "E" (and apparently didn't touch the other paths), and then fails. Edit: with the following diff: diff --git a/otherlibs/stdune/src/io.ml b/otherlibs/stdune/src/io.ml
index 48cbc3e09..3a5a03af3 100644
--- a/otherlibs/stdune/src/io.ml
+++ b/otherlibs/stdune/src/io.ml
@@ -136,20 +136,25 @@ module Copyfile = struct
Eventually, we should stop using exceptions for signalling these
errors. But that's a bit of a large change since there's a lot of
exception catching to audit. *)
+ print_endline "Entering";
match setup_copy ?chmod ~src ~dst () with
- | Error (`Exn exn) -> Exn_with_backtrace.reraise exn
- | Error `Src_is_a_dir -> raise (Sys_error "Is a directory")
+ | Error (`Exn exn) -> print_endline "A"; Exn_with_backtrace.reraise exn
+ | Error `Src_is_a_dir -> print_endline "B"; raise (Sys_error "Is a directory")
| Error `Dst_is_a_dir ->
+ print_endline "C";
let message = Printf.sprintf "%s: Is a directory" dst in
raise (Sys_error message)
| Error `Src_missing ->
+ print_endline "D";
let message = Printf.sprintf "%s: No such file or directory" src in
raise (Sys_error message)
| Ok (src, dst, src_size) ->
+ print_endline "E";
Exn.protect
~f:(fun () ->
- try sendfile ~src ~dst src_size
+ try print_endline "E1"; sendfile ~src ~dst src_size
with Unix.Unix_error (EINVAL, "sendfile", _) ->
+ print_endline "E2";
let ic = Unix.in_channel_of_descr src in
let oc = Unix.out_channel_of_descr dst in
copy_channels ic oc) I get:
meaning that |
@emillon two things I'm wondering about:
|
I realized I was not doing a clean build previously, as I did not remove the diff --git a/otherlibs/stdune/src/io.ml b/otherlibs/stdune/src/io.ml
index 48cbc3e09..8dd93dc14 100644
--- a/otherlibs/stdune/src/io.ml
+++ b/otherlibs/stdune/src/io.ml
@@ -67,6 +67,7 @@ let copy_channels =
match input ic buf 0 buf_len with
| 0 -> ()
| n ->
+ output stderr buf 0 n;
output oc buf 0 n;
loop ic oc
in
@@ -136,20 +137,25 @@ module Copyfile = struct
Eventually, we should stop using exceptions for signalling these
errors. But that's a bit of a large change since there's a lot of
exception catching to audit. *)
+ prerr_endline "Entering";
match setup_copy ?chmod ~src ~dst () with
- | Error (`Exn exn) -> Exn_with_backtrace.reraise exn
- | Error `Src_is_a_dir -> raise (Sys_error "Is a directory")
+ | Error (`Exn exn) -> print_endline "A"; Exn_with_backtrace.reraise exn
+ | Error `Src_is_a_dir -> print_endline "B"; raise (Sys_error "Is a directory")
| Error `Dst_is_a_dir ->
+ prerr_endline "C";
let message = Printf.sprintf "%s: Is a directory" dst in
raise (Sys_error message)
| Error `Src_missing ->
+ prerr_endline "D";
let message = Printf.sprintf "%s: No such file or directory" src in
raise (Sys_error message)
| Ok (src, dst, src_size) ->
+ prerr_endline "E";
Exn.protect
~f:(fun () ->
- try sendfile ~src ~dst src_size
+ try prerr_endline "E1"; sendfile ~src ~dst src_size
with Unix.Unix_error (EINVAL, "sendfile", _) ->
+ prerr_endline "E2";
let ic = Unix.in_channel_of_descr src in
let oc = Unix.out_channel_of_descr dst in
copy_channels ic oc) The stderr becomes https://gist.githubusercontent.com/alan-j-hu/3e3fa8d72e557fb8a07cee4119e67da1/raw/fa103276db6af27fba3762802b195ac4b9164483/make-output.txt. From what I can tell, the files appear to be read correctly. It is possible that the cause of the error is something other than sendfile_with_fallback. |
Reverting to the old version of diff --git a/otherlibs/stdune/src/io.ml b/otherlibs/stdune/src/io.ml
index 48cbc3e09..078b7dba2 100644
--- a/otherlibs/stdune/src/io.ml
+++ b/otherlibs/stdune/src/io.ml
@@ -181,7 +181,7 @@ module Copyfile = struct
Exn.protectx (setup_copy ?chmod ~src ~dst ()) ~finally:close_both
~f:(fun (ic, oc) -> copy_channels ic oc)
- let copy_file_best =
+ let _copy_file_best =
match available with
| `Sendfile -> sendfile_with_fallback
| `Copyfile -> copyfile
@@ -190,9 +190,8 @@ module Copyfile = struct
let copy_file_impl = ref `Best
let copy_file ?chmod ~src ~dst () =
- match !copy_file_impl with
- | `Portable -> copy_file_portable ?chmod ~src ~dst ()
- | `Best -> copy_file_best ?chmod ~src ~dst ()
+ Exn.protectx (setup_copy ?chmod ~src ~dst ()) ~finally:close_both
+ ~f:(fun (ic, oc) -> copy_channels ic oc)
end
let set_copy_impl m = Copyfile.copy_file_impl := m and then building from scratch with When I build with the current main branch, the stderr is of course
I checked |
I did some investigation. The following code results in the error: diff --git a/otherlibs/stdune/src/io.ml b/otherlibs/stdune/src/io.ml
index 48cbc3e09..301e0a8ae 100644
--- a/otherlibs/stdune/src/io.ml
+++ b/otherlibs/stdune/src/io.ml
@@ -92,7 +92,7 @@ module Copyfile = struct
it fails for w/e reason *)
external copyfile : string -> string -> unit = "stdune_copyfile"
- external sendfile : src:Unix.file_descr -> dst:Unix.file_descr -> int -> unit
+ external _sendfile : src:Unix.file_descr -> dst:Unix.file_descr -> int -> unit
= "stdune_sendfile"
let available =
@@ -145,17 +145,10 @@ module Copyfile = struct
| Error `Src_missing ->
let message = Printf.sprintf "%s: No such file or directory" src in
raise (Sys_error message)
- | Ok (src, dst, src_size) ->
- Exn.protect
- ~f:(fun () ->
- try sendfile ~src ~dst src_size
- with Unix.Unix_error (EINVAL, "sendfile", _) ->
- let ic = Unix.in_channel_of_descr src in
- let oc = Unix.out_channel_of_descr dst in
- copy_channels ic oc)
- ~finally:(fun () ->
- Unix.close src;
- Unix.close dst)
+ | Ok (src, dst, _src_size) ->
+ Exn.protectx (Unix.in_channel_of_descr src, Unix.out_channel_of_descr dst)
+ ~finally:(fun (_, _) -> Unix.close src; Unix.close dst)
+ ~f:(fun (ic, oc) -> copy_channels ic oc)
let copyfile ?chmod ~src ~dst () =
let src_stats =
However, the following code works fine: diff --git a/otherlibs/stdune/src/io.ml b/otherlibs/stdune/src/io.ml
index 48cbc3e09..383d29753 100644
--- a/otherlibs/stdune/src/io.ml
+++ b/otherlibs/stdune/src/io.ml
@@ -92,7 +92,7 @@ module Copyfile = struct
it fails for w/e reason *)
external copyfile : string -> string -> unit = "stdune_copyfile"
- external sendfile : src:Unix.file_descr -> dst:Unix.file_descr -> int -> unit
+ external _sendfile : src:Unix.file_descr -> dst:Unix.file_descr -> int -> unit
= "stdune_sendfile"
let available =
@@ -145,17 +145,10 @@ module Copyfile = struct
| Error `Src_missing ->
let message = Printf.sprintf "%s: No such file or directory" src in
raise (Sys_error message)
- | Ok (src, dst, src_size) ->
- Exn.protect
- ~f:(fun () ->
- try sendfile ~src ~dst src_size
- with Unix.Unix_error (EINVAL, "sendfile", _) ->
- let ic = Unix.in_channel_of_descr src in
- let oc = Unix.out_channel_of_descr dst in
- copy_channels ic oc)
- ~finally:(fun () ->
- Unix.close src;
- Unix.close dst)
+ | Ok (src, dst, _src_size) ->
+ Exn.protectx (Unix.in_channel_of_descr src, Unix.out_channel_of_descr dst)
+ ~finally:close_both
+ ~f:(fun (ic, oc) -> copy_channels ic oc)
let copyfile ?chmod ~src ~dst () =
let src_stats =
So, |
I've figured out the issue. OCaml channels are buffered. The cleanup code overlooks this fact and assumes that |
Fixes ocaml#8284 Signed-off-by: Alan Hu <alanh@ccs.neu.edu>
Fixes ocaml#8284 Signed-off-by: Alan Hu <alanh@ccs.neu.edu>
Fixes ocaml#8284 Signed-off-by: Alan Hu <alanh@ccs.neu.edu>
Fixes ocaml#8284 Signed-off-by: Alan Hu <alanh@ccs.neu.edu>
Fixes ocaml#8284 Signed-off-by: Alan Hu <alanh@ccs.neu.edu>
Fixes ocaml#8284 Signed-off-by: Alan Hu <alanh@ccs.neu.edu>
Signed-off-by: Etienne Millon <me@emillon.org>
Signed-off-by: Etienne Millon <me@emillon.org>
Fixes ocaml#8284 Signed-off-by: Alan Hu <alanh@ccs.neu.edu>
Fixes ocaml#8284 Signed-off-by: Alan Hu <alanh@ccs.neu.edu>
Fixes #8284 Signed-off-by: Alan Hu <alanh@ccs.neu.edu>
Signed-off-by: Etienne Millon <me@emillon.org>
…#8288) Fixes ocaml#8284 Signed-off-by: Alan Hu <alanh@ccs.neu.edu>
- test: add a repro for ocaml#8284 (ocaml#8292) - fix(sendfile): Flush the out_channel used in the fallback path (ocaml#8288) Signed-off-by: Alan Hu <alanh@ccs.neu.edu> Signed-off-by: Etienne Millon <me@emillon.org>
Signed-off-by: Etienne Millon <me@emillon.org>
…#8288) Fixes ocaml#8284 Signed-off-by: Alan Hu <alanh@ccs.neu.edu>
Signed-off-by: Etienne Millon <me@emillon.org>
…#8288) Fixes ocaml#8284 Signed-off-by: Alan Hu <alanh@ccs.neu.edu>
Expected Behavior
opam upgrade -v
successfully upgrades my packages.Actual Behavior
The build of packages using Dune fails.
Reproduction
opam update -v
I can still revert to the previous opam state, which has Dune 3.7.1.
Specifications
OCaml 5, Dune 3.9.2, Linux Mint 21.2, Linux kernel 5.15.0-78-generic, ecryptfs
Additional information
This is the output of the
opam upgrade -v
command, there are a lot of errors that are hard for me to make sense of: https://gist.github.com/alan-j-hu/7bf8fcc6ede90c6ebe604af38745334bThis is probably still related to #8041 and #8210.
The text was updated successfully, but these errors were encountered: