Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005184OCaml~DO NOT USE (was: OCaml general)public2010-11-29 16:402012-09-25 20:06
Assigned Toxleroy 
PlatformOSOS Version
Product Version3.11.2 
Target VersionFixed in Version 
Summary0005184: Bigarray.*.map_file doesn't work with some offsets on Windows
DescriptionThe function map_file from submodules of Bigarray module doesn't work as expected on Windows platform with some values of ~pos argument. Here's the example:

(* ======================================================= *)
open Bigarray ;;
open Unix ;;

let fd= openfile "z.out" [O_RDWR; O_CREAT; O_TRUNC] 0o666 in
        let arr = Array1.map_file fd ~pos:(Int64.of_int 4096)
        int c_layout true 1 in
        arr.{0} <- 10
close fd
(* ======================================================= *)

Instead of writing the number to file the program yields:
Fatal error: exception Sys_error("The base address or the file offset specified does not have the proper alignment.

There's no such problem on Unix environment.
Additional InformationThe problem is caused by the following: dwPageSize is used instead of dwAllocationGranularity as a unit when offset is determined for CreateFileMapping in file mmap_win32.c.

Replacing dwPageSize by dwAllocationGranularity everywhere in mmap_win32.c and recompilation of Bigarray library solved the problem for me.
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
doligez (administrator)
2011-05-20 16:01

I can't reproduce this on windows 7 and cygwin with 3.12.0 or 3.11.2.
Is this with mingw or the native MS port ?
Vadim_Z (reporter)
2011-05-20 21:02

I've seen this behavior for native MS port. I expect that mingw port also fails there, as it uses the same file mmap_win32.c.

On the other side, Cygwin port doesn't have this deficiency as it uses file mmap_unix.c and mmap function provided by the Cygwin environment.
xleroy (administrator)
2011-06-04 15:54

Suggested fix to mmap_win32.c applied in 3.12 bugfix branch, will go in 3.12.1. Not tested.

- Issue History
Date Modified Username Field Change
2010-11-29 16:40 Vadim_Z New Issue
2011-05-20 16:01 doligez Note Added: 0005920
2011-05-20 16:01 doligez Status new => feedback
2011-05-20 21:02 Vadim_Z Note Added: 0005924
2011-06-04 15:54 xleroy Note Added: 0005971
2011-06-04 15:54 xleroy Status feedback => resolved
2011-06-04 15:54 xleroy Resolution open => fixed
2011-06-04 19:08 xleroy Status resolved => assigned
2011-06-04 19:08 xleroy Assigned To => xleroy
2011-06-04 19:08 xleroy Status assigned => resolved
2012-09-25 20:06 xleroy Status resolved => closed
2017-02-23 16:36 doligez Category OCaml general => -OCaml general
2017-03-03 17:55 doligez Category -OCaml general => -(deprecated) general
2017-03-03 18:01 doligez Category -(deprecated) general => ~deprecated (was: OCaml general)
2017-03-06 17:04 doligez Category ~deprecated (was: OCaml general) => ~DO NOT USE (was: OCaml general)

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker