RFR: 8315739: Missing null check in os::vm_min_address

David Holmes dholmes at openjdk.org
Tue Sep 12 00:48:40 UTC 2023


On Wed, 6 Sep 2023 15:29:30 GMT, Daniel Jeliński <djelinski at openjdk.org> wrote:

> Please review this fix for handling of file `/proc/sys/vm/mmap_min_addr` which does not exist on WSL1.
> 
> This fixes a crash if the file is absent, and a file handle leak (missing `fclose`) when the file is present.
> 
> Linux tier1 tests clean.

Changes requested by dholmes (Reviewer).

src/hotspot/os/linux/os_linux.cpp line 4258:

> 4256:     FILE* f = os::fopen("/proc/sys/vm/mmap_min_addr", "r");
> 4257:     if (f != nullptr) {
> 4258:       if (fscanf(f, "%zu", &value) != 1) {

I think you can simplify the whole thing by only making this one change:

if (f != nullptr && fscanf(f, "%zu", &value) != 1) {

the "assignment" in the null case will be handled by the existing:

value = MAX2(_vm_min_address_default, value);

-------------

PR Review: https://git.openjdk.org/jdk/pull/15596#pullrequestreview-1621064982
PR Review Comment: https://git.openjdk.org/jdk/pull/15596#discussion_r1322239263


More information about the hotspot-runtime-dev mailing list