bos
bos copied to clipboard
'Value too large for defined data type' errors with 32-bit OCaml
The smallest reproducible example is available at https://github.com/diskuv/diskuvbox/blob/e1d1819d4718a061cfa661b8d8ff21d1f27e04d5/support/ .
Assuming test files:
$ ls -lh _build/test_20m _build/test_5gb
-rw-r--r-- 1 root root 20M Aug 7 03:43 _build/test_20m
-rw-r--r-- 1 root root 5.0G Aug 7 03:43 _build/test_5gb
and an 32-bit OCaml interpreter or compiler:
#use "topfind";;
#require "bos";;
#require "fmt";;
#require "fpath";;
open Bos;;
let print_result =
Fmt.pr "Result: %a@\n"
Rresult.R.(
pp
~ok:Fmt.(const string "Ok ( Fpath.v {|" ++ Fpath.pp ++ const string "|} )")
~error:Fmt.(const string "Error ( `Msg {|" ++ pp_msg ++ const string "|} )"))
;;
print_endline "\n\n========= 20 MB ========\n\n";;
print_result @@ OS.File.must_exist (Fpath.v "_build/test_20m") ;;
print_endline "\n\n========= 5 GB ========\n\n";;
print_result @@ OS.File.must_exist (Fpath.v "_build/test_5gb") ;;
we get:
========= 20 MB ========
- : unit = ()
# Result: Ok ( Fpath.v {|_build/test_20m|} )
- : unit = ()
#
========= 5 GB ========
- : unit = ()
# Result: Error ( `Msg {|file _build/test_5gb must exist: Value too large for defined data type|} )
- : unit = ()
#
I can reproduce the problem in both Linux x86 and Windows x86.
You can run it yourself by cloning https://github.com/diskuv/diskuvbox and running sh support/test-32bit.sh on a Linux machine that has Docker.
FYI: I have no problem using Bos to copy a 5GB file using OS.File.with_output. The problem seems to be with stat calls in other Bos functions.
Unix.stat is used I guess Unix.LargeFile.stat should be used.