You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 5463 Reporter:@mjambon Status: closed (set by @xavierleroy on 2013-08-31T10:49:00Z) Resolution: fixed Priority: normal Severity: minor OS: Linux OS Version: 2.6.34 Version: 3.12.1 Fixed in version: 4.00.0+dev Category: ~DO NOT USE (was: OCaml general) Monitored by: mehdi @dbuenzli
Bug description
Bigarray.Array1.map_file fails if the array to be created is empty. This is a slight annoyance because it is not documented in the manual. I don't know where the various implementations of mmap stand, but a warning note would be welcome if a fix is not possible.
uname -v
Darwin Kernel Version 10.8.0: Tue Jun 7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386
the man says :
[...]
COMPATIBILITY
mmap() now returns with errno set to EINVAL in places that historically
succeeded. The rules have changed as follows:
o The flags parameter must specify either MAP_PRIVATE or MAP_SHARED.
o The size parameter must not be 0.
o The off parameter must be a multiple of pagesize, as returned by
sysconf().
@dbuenzli: map_file allows it to map files at offsets that are not a multiple of the pagesize. This is done by rounding down to the next multiple, and hiding the intitial part of the mapping from the user. What I want to say is that it does not necessarily matter what mmap allows when there is a way to emulate more general behavior.
I think an emulation for size=0 is very easy - just return the empty array instead (don't call mmap at all).
Original bug ID: 5463
Reporter: @mjambon
Status: closed (set by @xavierleroy on 2013-08-31T10:49:00Z)
Resolution: fixed
Priority: normal
Severity: minor
OS: Linux
OS Version: 2.6.34
Version: 3.12.1
Fixed in version: 4.00.0+dev
Category: ~DO NOT USE (was: OCaml general)
Monitored by: mehdi @dbuenzli
Bug description
Bigarray.Array1.map_file fails if the array to be created is empty. This is a slight annoyance because it is not documented in the manual. I don't know where the various implementations of mmap stand, but a warning note would be welcome if a fix is not possible.
On Linux, "man mmap" says in the ERRORS section:
Steps to reproduce
$ cat > mapfile.ml
(* ocamlopt -o mapfile unix.cmxa bigarray.cmxa mapfile.ml *)
let empty = Filename.temp_file "empty" ".dat";;
let fd = Unix.openfile empty [Unix.O_RDONLY] 0;;
Bigarray.Array1.map_file fd Bigarray.char Bigarray.c_layout false 0
$ ocamlopt -o mapfile unix.cmxa bigarray.cmxa mapfile.ml
$ ./mapfile
Fatal error: exception Sys_error("Invalid argument")
The text was updated successfully, but these errors were encountered: