Integrated: 8349554: [UBSAN] os::attempt_reserve_memory_between reported applying non-zero offset to non-null pointer produced null pointer

SendaoYan syan at openjdk.org
Sat Feb 8 13:14:16 UTC 2025


On Fri, 7 Feb 2025 02:25:10 GMT, SendaoYan <syan at openjdk.org> wrote:

> Hi all,
> 
> Function 'os::attempt_reserve_memory_between(char*, char*, size_t, size_t, bool)' 'src/hotspot/share/runtime/os.cpp' reported "runtime error: applying non-zero offset to non-null pointer 0x000000001000 produced null pointer" by address sanitizer. Gtest in function 'os_attempt_reserve_memory_between_combos_vm_Test::TestBody'  at file test/hotspot/gtest/runtime/test_os_reserve_between.cpp call 'os::attempt_reserve_memory_between (min=0x0, max=0x1000, bytes=4096, alignment=4096, randomize=true)' trigger this failure. Before this PR, the pointer var `hi_end` get value from `max` 0x1000, and then apply offset `bytes`, and `max` equals `bytes`, thus address sanitizer report this failure.
> 
> This PR change from `hi_end < bytes` to `hi_end <= bytes` will eliminate the undefined behaviour. Risk is low.
> 
> Additional testing:
> 
> - [x] jtreg tests(which include tier1/2/3 etc.) on linux-x64
> - [x] jtreg tests(which include tier1/2/3 etc.) on linux-aarch64

This pull request has now been integrated.

Changeset: 8f6ccde9
Author:    SendaoYan <syan at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/8f6ccde9829ea0e4fe1c087e68bec4d9efb55c64
Stats:     1 line in 1 file changed: 0 ins; 0 del; 1 mod

8349554: [UBSAN] os::attempt_reserve_memory_between reported applying non-zero offset to non-null pointer produced null pointer

Reviewed-by: stefank, stuefe

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

PR: https://git.openjdk.org/jdk/pull/23508


More information about the hotspot-runtime-dev mailing list