RFR: 8342504: Remove NMT header and footer canaries

Johan Sjölen jsjolen at openjdk.org
Fri Nov 15 10:48:03 UTC 2024


On Wed, 23 Oct 2024 15:08:20 GMT, Gerard Ziemski <gziemski at openjdk.org> wrote:

>> Today NMT has two canaries: A header and a footer canary. These enable mainly two things:
>> 
>> 1. For NMT to aid in describing a pointer
>> 2. A basic form of out-of-bounds protection
>> 
>> With the introduction of UBSan and Asan into OpenJDK we have gained stronger tools for this sort of analysis, without requiring NMT to be activated. Therefore, I believe that point 2 is no longer something that NMT needs to support. For point number one, we will unfortunately be losing this ability.
>> 
>> I want to delete these canaries to open up a few free bytes. These can allow us to have "practically unlimited" (4 bytes) of memory tags.
>> 
>> tier1-tier2 tests succeeded.
>> 
>> I am awaiting discussion on the Hotspot-dev mailing list, but keeping this PR open for review.
>
> src/hotspot/share/nmt/mallocTracker.cpp line 227:
> 
>> 225: // totally failproof and may give a wrong answer. It is safe in that it will never
>> 226: // crash, even when encountering unmapped memory.
>> 227: bool MallocTracker::print_pointer_information(const void* p, outputStream* st) {
> 
> It looks like the only thing that had to go was `candidate->looks_valid()`
> 
> Isn't it useful to keep the rest of this code though?

We've also removed the `is_live()` call. So now we really can't make a reasonable guess whether a potential pointer really points to a `MallocHeader`. Since, in my opinion, we can't find a reasonable candidate (not sufficient clues), I decided to remove the code.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21560#discussion_r1843575879


More information about the hotspot-runtime-dev mailing list