RFR: 8264827: Large mapped buffer/segment crash the VM when calling isLoaded
Chris Hegarty
chegar at openjdk.java.net
Fri Apr 9 10:19:21 UTC 2021
On Wed, 7 Apr 2021 15:45:30 GMT, Chris Hegarty <chegar at openjdk.org> 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
More information about the core-libs-dev
mailing list