Integrated: 8349623: [ASAN] Gtest os_linux.glibc_mallinfo_wrapper_vm fails
SendaoYan
syan at openjdk.org
Fri Mar 7 09:18:02 UTC 2025
On Fri, 7 Feb 2025 07:01:18 GMT, SendaoYan <syan at openjdk.org> wrote:
> Hi all,
>
> The glibc function `mallinfo()` do do not work with -fsanitize=adddress, maybe it's [limitation or bug](https://github.com/google/sanitizers/issues/1845) of address sanitizer . Should we disable the gtest 'os_linux.glibc_mallinfo_wrapper_vm' when configure and build with address sanitizer. The macro `ADDRESS_SANITIZER` will always pass to gcc/clang/microsoft compiler when enable address sanitizer. So this PR check the macro `ADDRESS_SANITIZER` to enable the test or not.
>
> On the other hand, this test get malloc usage information by call `os::Linux::get_mallinfo` and check "total allocation values" greater than `2K` before allocate the memort by `malloc(2K)`. Call `os::Linux::get_mallinfo` should after `malloc(2K)`.
>
> Below code snippet can demonstrate the glibc function `mallinfo()` do do not work with -fsanitize=adddress.
>
>
> #include <stdio.h>
> #include <malloc.h>
>
> int main() {
> struct mallinfo info;
> info = mallinfo();
>
> printf("%d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n", info.arena, info.ordblks, info.smblks, info.hblks, info.hblkhd, info.usmblks, info.fsmblks, info.uordblks, info.fordblks, info.keepcost);
>
> char* ptr = malloc(0x10000);
> info = mallinfo();
>
> printf("%d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n", info.arena, info.ordblks, info.smblks, info.hblks, info.hblkhd, info.usmblks, info.fsmblks, info.uordblks, info.fordblks, info.keepcost);
>
> free(ptr);
> return 0;
> }
>
>
> - Without -fsanitize=address, mallinfo() works normally.
>
>
> gcc mallinfo.c && ./a.out
> 0, 1, 0, 0, 0, 0, 0, 0, 0, 0
> 135168, 1, 0, 0, 0, 0, 0, 67248, 67920, 67920
>
>
> - With -fsanitize=address, mallinfo() works abnormally.
>
>
> gcc -fsanitize=address mallinfo.c && ./a.out
> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
This pull request has now been integrated.
Changeset: 155697fc
Author: SendaoYan <syan at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/155697fc0ed69f1b4f871b00fe67685177bad59a
Stats: 7 lines in 1 file changed: 4 ins; 2 del; 1 mod
8349623: [ASAN] Gtest os_linux.glibc_mallinfo_wrapper_vm fails
Reviewed-by: stuefe
-------------
PR: https://git.openjdk.org/jdk/pull/23510
More information about the hotspot-runtime-dev
mailing list