RFR: 8369393: NMT: poison the canaries of malloc header under ASAN build [v11]

Afshin Zafari azafari at openjdk.org
Wed Oct 15 10:16:58 UTC 2025


On Wed, 15 Oct 2025 07:43:04 GMT, Johan Sjölen <jsjolen at openjdk.org> wrote:

>> Afshin Zafari has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   another NOT_LP64
>
> src/hotspot/share/nmt/mallocHeader.hpp line 96:
> 
>> 94:  public:
>> 95:   AsanPoisoningHelper() = delete;
>> 96:   AsanPoisoningHelper(U* addr) : _memory_region(addr) {
> 
> This is what I meant, then you don't need any casting when passing along the args.
> 
> ```c++
> template<typename T>
> class AsanPoisoningHelper {
> 
> public:
>   AsanPoisoningHelper(T* addr) : _memory_region(addr) {
>     #if INCLUDE_ASAN
>       ASAN_UNPOISON_MEMORY_REGION(reinterpret_cast<char*>(_memory_region), sizeof(T));
>     #endif
>   }
> };

since we are using `const ...` types for `T`, we cannot use `reinterpret_cast`. 
Casting is avoided everywhere by introducing second template parameter `U`.

> test/hotspot/gtest/nmt/test_nmt_buffer_overflow_detection.cpp line 330:
> 
>> 328:   a = 3;
>> 329:   EXPECT_EQ(a, 3);
>> 330: }
> 
> If the intent of this test is to test ASAN when it's disabled, then move the test to before the ASAN-inclusion test, and delete the `APH<void>` template specialization.

Not needed. Removed.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27685#discussion_r2431982731
PR Review Comment: https://git.openjdk.org/jdk/pull/27685#discussion_r2431975022


More information about the hotspot-runtime-dev mailing list