RFR: 8369393: NMT: poison the malloc header and footer under ASAN build [v2]

Paul Hübner phubner at openjdk.org
Wed Dec 17 09:02:27 UTC 2025


On Wed, 17 Dec 2025 08:58:42 GMT, Afshin Zafari <azafari at openjdk.org> wrote:

>> Under ASAN builds and when NMT is enabled, the header and footer of MallocHeader are poisoned/unpoisoned at malloc/realloc/free times.
>> Checking the integrity of memory blocks is off under ASAN builds.
>
> Afshin Zafari has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains eight additional commits since the last revision:
> 
>  - Merge remote-tracking branch 'origin/master' into asan_poison_malloc_hdr_ftr_v2
>  - removed extra newlines.
>  - fixes.
>  - inlining
>  - review comments applied.
>  - revision
>  - jtreg test excluded when ASAN is enabled.
>  - 8369393: NMT: poison the malloc header and footer under ASAN build

src/hotspot/share/nmt/mallocHeader.inline.hpp line 170:

> 168:   ASAN_UNPOISON_MEMORY_REGION(header->footer_address(), footer_size);
> 169:   resolve_checked(memblock);
> 170:   header->mark_block_as_dead();

Unrelated to this PR: is there a reason we `mark_block_as_dead()` but `revive()` as opposed to `mark_block_as_revived()`?

src/hotspot/share/runtime/os.cpp line 724:

> 722:       void* const new_outer_ptr = permit_forbidden_function::realloc(header, new_outer_size);
> 723:       bool realloc_succeeded = new_outer_ptr != nullptr;
> 724:       success = realloc_succeeded;

Nit: `realloc_succeeded` is only used here. Got briefly confused why there were two successes while reviewing.
Suggestion:

      success = new_outer_ptr != nullptr; // reallocation succeeded

src/hotspot/share/runtime/os.cpp line 739:

> 737: #endif
> 738: 
> 739:         success = true;

Redundant assignment?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/28503#discussion_r2585281027
PR Review Comment: https://git.openjdk.org/jdk/pull/28503#discussion_r2585259935
PR Review Comment: https://git.openjdk.org/jdk/pull/28503#discussion_r2585267933


More information about the hotspot-runtime-dev mailing list