On Wed, 7 Apr 2021 15:45:30 GMT, Chris Hegarty <[email protected]> wrote:
> Avoid overflow when calculating the number of pages for large mapped segment
> sizes.
Note for reviewers on the test. A 3GB file is sufficient to demonstrate the
issue in the old code, as follows (with a 4K page size, since the narrowing
cast of size is the significant issue):
jshell> int pageSize() { return 4 * 1024; }
| created method pageSize()
jshell> int pageCount(long size) { return (int)(size + (long)pageSize() - 1L) /
pageSize(); }
| created method pageCount(long)
jshell> pageCount(3L * 1024L * 1024L * 1024L)
$3 ==> -262143
-------------
PR: https://git.openjdk.java.net/jdk/pull/3378