On Fri, 24 Jan 2025 09:53:43 GMT, SendaoYan <s...@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

This pull request has now been integrated.

Changeset: bb528d5a
Author:    SendaoYan <s...@openjdk.org>
URL:       
https://git.openjdk.org/jdk/commit/bb528d5ad6f28e9c1bc4e283d40c70489465bd00
Stats:     2 lines in 1 file changed: 0 ins; 0 del; 2 mod

8348567: [ASAN] Memory access partially overflows by NativeCallStack

Reviewed-by: jsjolen, dholmes

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

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

Reply via email to