RFR: 8286876: NMT.test_unaliged_block_address_vm_assert fails if using clang toolchain [v2]

Johan Sjölen jsjolen at openjdk.org
Mon Dec 5 13:16:44 UTC 2022


On Fri, 2 Dec 2022 16:03:29 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

>> Johan Sjölen has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Generate assert_block_integrity thru templated function
>
> src/hotspot/share/services/mallocHeader.inline.hpp line 88:
> 
>> 86: inline MallocHeader* MallocHeader::assert_block_integrity(const void* memblock) {
>> 87:   char msg[256];
>> 88:   address corruption = NULL;
> 
> Note that it is not necessary to test the supposed malloc header pointer for validity. You can also do the test on the memblock itself. Since that one must always be malloc-aligned, and the malloc header is 16 bytes, it does not matter on which pointer you do the test.

Yes, but we need the header pointer for the fatal printing and `print_block_on_error()`, right?

> src/hotspot/share/services/mallocTracker.hpp line 322:
> 
>> 320:   static inline const MallocHeader* malloc_header(const void *memblock) {
>> 321:     assert(memblock != NULL, "NULL pointer");
>> 322:     return (const MallocHeader*)((const char*)memblock - sizeof(MallocHeader));
> 
> Pre-existing, but I feel like these should really live in MallocHeader, as companions to your new assert function.

Yeah, these are still used by `os::realloc` and `MallocTracker::print_pointer_information`, so should be taken care of in a different RFE imo.

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

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


More information about the hotspot-runtime-dev mailing list