RFR: 8348567: [ASAN] Memory access partially overflows by NativeCallStack
Johan Sjölen
jsjolen at openjdk.org
Wed Jan 29 10:25:45 UTC 2025
On Fri, 24 Jan 2025 09:53:43 GMT, SendaoYan <syan at openjdk.org> wrote:
> Hi all,
> This PR fix a undefined behaviour in 'CollisionsReceiveDifferentIndexes' testcase
> locate in 'test/hotspot/gtest/nmt/test_nmt_nativecallstackstorage.cpp' file when call `NativeCallStack::NativeCallStack` function. Before this PR, 'CollisionsReceiveDifferentIndexes' test allocate 4 type variable `i` and then pass the address `&i`, but in 'NativeCallStack' function read the pointer as 8 types, so the AddressSanitizer report "Memory access partially overflows variable i". This PR change the variable `i` to `size_t` to avoid this undefined behaviour.
> Change has been verified locally, test-fix only, no risk.
>
> Below code snippet can reproduce the same issue:
>
>
> #include <stdio.h>
> typedef unsigned char u_char;
> typedef u_char* address;
> int main()
> {
> int i = 0;
> address* pc = (address*)(&i);
> address _stack = pc[0];
> printf("_stack = %p\n", _stack);
> return 0;
> }
>
>
> Reproduce command:
>
> clang -g3 -Wall -Wextra -fsanitize=address -fsanitize=leak -fsanitize=undefined partially-overflows.c && ./a.out
Hi,
Thank you for the fix. This is correct. Context to the other reviewers: We just needed *some* unique "addresses", as we know that these aren't going to be dereferenced it didn't matter what the addresses are.
-------------
Marked as reviewed by jsjolen (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/23294#pullrequestreview-2580590360
More information about the hotspot-runtime-dev
mailing list