RFR: 8286637: (fc) Memory mapped regions bigger than 2GB do not work correctly on Windows
Maurizio Cimadamore
mcimadamore at openjdk.java.net
Thu May 12 20:58:53 UTC 2022
On Thu, 12 May 2022 20:52:20 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> Cast the last parameter `dwNumberOfBytesToMap` of `MapViewOfFile()` to a `SIZE_T`, not a `DWORD`, to avoid truncation.
>
> test/jdk/java/nio/channels/FileChannel/LargeMapTest.java line 64:
>
>> 62: MemorySegment mappedMemorySegment = MemorySegment.mapFile(p, 0,
>> 63: p.toFile().length(), FileChannel.MapMode.READ_WRITE,
>> 64: ResourceScope.newSharedScope());
>
> Note that I've integrated JEP 424. As a result, you will need to update this test in the following ways:
>
> * replace `jdk.incubator.foreign` with `java.lang.foreign`
> * add @enablePreview to the test
> * replace `ResourceScope` with `MemorySession`
> * the `map` method for segments has moved into `FileChannel`, for constistency
>
> In addition, I think it would be better to use `MemorySession.openImplicit()` as session/scope parameter, since we don't want to call close explicitly.
Would it be worth running the test on all platforms, rather than on windows only? And should we test other size combinations and offsets? For instance, Windows has some tricky code to split size and offset of the mapping - the test in this PR checks that the size is split correctly, but it doesn't check the mapping offset (which the test sets to 0).
Would be interesting perhaps to add a case which creates the mapping of a 8G file at offset 3G and then starts iterating.
-------------
PR: https://git.openjdk.java.net/jdk/pull/8686
More information about the nio-dev
mailing list