[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: --with-tests and address sanitizer
From: |
Bruno Haible |
Subject: |
Re: --with-tests and address sanitizer |
Date: |
Mon, 05 Sep 2022 22:17:43 +0200 |
Hi Vivien,
> Are my memory leaks a known problem? Is there a way to fix them?
It is known that the address sanitizer reports important problems
(e.g. accessing invalid memory) and unimportant problems (e.g. memory
leaks) together. It is your duty, as a user, to let it report only
the important problems.
Similarly for the undefined-behaviour sanitizer. Here I use clang and
CC="$CC
-fsanitize=undefined,signed-integer-overflow,shift,integer-divide-by-zero
-fno-sanitize=pointer-overflow"
CXX="$CXX
-fsanitize=undefined,signed-integer-overflow,shift,integer-divide-by-zero
-fno-sanitize=pointer-overflow"
to get only the important problems reported.
Regarding memory leaks in particular, we had a discussion a while ago:
https://lists.gnu.org/archive/html/bug-gnulib/2020-05/threads.html
> If I try to include the gnulib tests with my project, and build with
> address sanitizer, then almost all tests fail, many of which because of
> 64 bytes allocated in argz_add_sep
Huh? *Many* tests fail, because of this one function which is hardly used
anywhere?
> a few others are because the amount of bytes required for an allocation
> is too large
That's an expected test failure, then.
> and asan detects a heap-buffer-overflow in test-free.
That's expected as well: 'test-free' stresses the memory management of
the process a lot.
> Is the heap-buffer-overflow test safe to run at all?
I don't know; you didn't even say whether you are using GCC or clang.
> Otherwise, is there a way to easily disable asan for the gnulib tests?
I would suggest to
- use compiler options that report important problems only,
- to get rid of 'test-free', pass the option --avoid=free-posix-tests
to gnulib-tool.
Bruno