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

Thomas Stuefe stuefe at openjdk.org
Mon Jan 16 19:11:12 UTC 2023


On Mon, 16 Jan 2023 18:33:07 GMT, Johan Sjölen <jsjolen at openjdk.org> wrote:

>> src/hotspot/share/services/mallocHeader.hpp line 154:
>> 
>>> 152:   // hex dump surrounding the broken block), then trigger a fatal error
>>> 153:   inline static const MallocHeader* resolve_checked(const void* memblock);
>>> 154:   inline static MallocHeader* resolve_checked(void* memblock);
>> 
>> Is there's a particular reason why in&out types need to match in terms of `const`? Does this work?
>> 
>> 
>>   inline static MallocHeader* resolve_checked(const void* memblock);
>
> Good question. Perhaps in this specific case we can throw away the const information, but it's difficult to discover whether that's true and doesn't look correct to a reader at a first glance. I think an extra method reduces reading complexity such that it is worth keeping.

You need both because you should be able to resolve a MallocHeader from a const payload pointer, but that should yield a const pointer too, not a non-const one. Yes, you could return a non-const header pointer, but that would be just bad const discipline.

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

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


More information about the hotspot-runtime-dev mailing list