Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005184OCamlOCaml generalpublic2010-11-29 16:402012-09-25 20:06
ReporterVadim_Z 
Assigned Toxleroy 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
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
begin
        let arr = Array1.map_file fd ~pos:(Int64.of_int 4096)
        int c_layout true 1 in
        arr.{0} <- 10
end;
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
(0005920)
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 ?
(0005924)
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.
(0005971)
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


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker