RFR: 8346866: [ASAN] memoryReserver.cpp reported applying non-zero offset to non-null pointer produced null pointer [v3]
Stefan Karlsson
stefank at openjdk.org
Thu Jan 2 11:30:35 UTC 2025
On Thu, 2 Jan 2025 09:21:13 GMT, SendaoYan <syan at openjdk.org> wrote:
>> Hi all,
>> This PR add an extra loop condition check `p2u(attach_point) > stepsize` in function `HeapReserver::Instance::try_reserve_range` to make sure the loop will not wrap around, and make UndefinedBehaviorSanitizer silent. The change do not change the original logic, risk is low.
>>
>> Additional testing:
>>
>> - [ ] jtreg tests(include tier1/2/3 etc., which include tests added by [PR22712](https://github.com/openjdk/jdk/pull/22712)) on linux-x64 with release build
>> - [ ] jtreg tests(include tier1/2/3 etc., which include tests added by [PR22712](https://github.com/openjdk/jdk/pull/22712)) on linux-x64 with fastdebug build
>> - [ ] jtreg tests(include tier1/2/3 etc., which include tests added by [PR22712](https://github.com/openjdk/jdk/pull/22712)) on linux-aarch64 with release build
>> - [ ] jtreg tests(include tier1/2/3 etc., which include tests added by [PR22712](https://github.com/openjdk/jdk/pull/22712)) on linux-aarch64 with fastdebug build
>
> SendaoYan has updated the pull request incrementally with one additional commit since the last revision:
>
> Update the comments
It's a little bit unfortunate that we now have two exist points in the for-loop. And the second one requires the comparison of a pointer with a delta. I'm also not sure if the `<=` in `if (p2u(attach_point) <= stepsize)` should be `<=` and not `<`.
Maybe one thing to explore is to use offsets in the loop logic instead:
for (size_t offset = attach_range;
offset <= attach_range; // Avoid wrap around.
offset -= stepsize) {
ReservedSpace reserved = try_reserve_memory(size, alignment, page_size, lowest_start + offset);
I'm not sure if this is better or not, but it at least keeps the exit condition to one place.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/22897#issuecomment-2567630467
More information about the hotspot-runtime-dev
mailing list